View Single Post
Old 11-16-2008, 06:11 PM   #1 (permalink)
Tanax
The Prestige
Upcoming Programmer Inquisitive 
 
Tanax's Avatar
 
Join Date: Sep 2007
Location: Sweden, Stockholm
Posts: 1,080
Thanks: 115
Tanax is on a distinguished road
Default 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:
class person
{

public 
$name;


THen you have this:

PHP Code:
class participants
{

public 
$person;

public function 
getName()
{
echo 
$person->name;
}


And this controller:
PHP Code:
include('participants.php');
include(
'person.php');

$person = new person();
$participants = new participants(); 
Then you want to set a variable inside participants with an object of the person, so you can use its function inside the class

PHP Code:
$participants->person $person
Then you edit the name of the person:

PHP Code:
$person->name 'Marcus'
If I then call the getName function:

PHP Code:
$participants->getName(); 
Will it echo out the name?


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..
__________________
Tanax is offline  
Reply With Quote