note 39372 added to language.references.arent

From: Date: Mon, 26 Jan 2004 12:57:23 +0000
Subject: note 39372 added to language.references.arent
Groups: php.notes 
Request: Send a blank email to php-notes+get-64201@lists.php.net to get a copy of this message
A not so simple Workaround...but still doable...have fun class My{ var $value; function get1(&$ref){ $ref[] =& $this; } function get2(&$ref){ $ref =& $this; } function get3(&$ref){ $ref = $this; } } $m = new My(); $m->value = 'foo'; $m->get1($ref=array()); $m1 =& $ref[0]; $m1->value = 'bar'; echo "\n".'Works but is ugly...'; echo "\n".' m:'. get_class($m) . '->value = '. $m->value; echo "\n".' m1:'. get_class($m1) . '->value = '. $m1->value; echo "\n".'Does not work because references are not pointers...'; $m->value = 'foo'; $m->get2($m2); $m2->value = 'bar'; echo "\n".' m:'. get_class($m) . '->value = '. $m->value; echo "\n".' m2:'. get_class($m2) . '->value = '. $m2->value; $m->value = 'foo'; $m->get3($m3); $m3->value = 'bar'; echo "\n".'Does not work becuase it is set to a copy'; echo "\n".' m:'. get_class($m) . '->value = '.$m->value; echo "\n".' m3:'. get_class($m3) . '->value = '. $m3->value; ---- Manual Page -- http://www.php.net/manual/en/language.references.arent.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+39372 Delete -- http://master.php.net/manage/user-notes.php?action=delete+39372&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+39372&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#64201) next »