![]() |
I was just thinking
Hi!
I was just thinking about something. First of all, the codesnippets in this thread will be little messy cause I'm coding them here in the WYSIWYG(or w.e it's called). Anyways, let's say you have here: PHP Code:
PHP Code:
PHP Code:
PHP Code:
PHP Code:
PHP Code:
As I said, messy. But anyways, my question could probably be summed up in: If you set a variable inside class b, with an instance of class a, and then change a value of class a OUTSIDE of class b(for example in a controller); Will class b get that change? Or is it like when you assign the object to a variable inside class b, it copies class a AT THAT MOMENT, and every change you make to that object will not be in the variable in class b? Fucked up question, but whatever, you get the point.. :-P |
In short: yes, no.
Class instances are assigned by reference in PHP5 meaning that any changes, even after the assignment, are reflected wherever that instance is used. If you want to create a copy, use clone. |
Ah I see.
Thank you! |
| All times are GMT. The time now is 09:19 PM. |
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0