php oo refrence class member

class Foo{
   private &$member;
   function __construct(&$member){ $this->member = &$member; }
   function doSmtg(){//changes member }
   function doSmtgElse(){//changes member }
$myMember = "";
foo = new Foo($myMember);
echo $myMember;

I am still pretty nez to php, so please bare with me…

I would like to pass $mymember to the constructor of Foo as a ref, so that the changes to it will directly be changed on the $myMember variable aswell.

My code is currently wrong, i get error about unexpected ‘&’ at private &$member;
So i guess something is wrong with my syntax on refrence usage ?

I tried to follow:


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s