Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:4260 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 24728 invoked by uid 1010); 30 Aug 2003 14:13:39 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 24705 invoked from network); 30 Aug 2003 14:13:39 -0000 Received: from unknown (HELO sccmmhc02.asp.att.net) (204.127.203.184) by pb1.pair.com with SMTP; 30 Aug 2003 14:13:39 -0000 Received: from insightbb.com (12-223-87-232.client.insightbb.com[12.223.87.232]) by sccmmhc02.asp.att.net (sccmmhc02) with SMTP id <20030830141339mm2004e1rpe>; Sat, 30 Aug 2003 14:13:39 +0000 Date: Sat, 30 Aug 2003 10:13:37 -0400 Content-Type: text/plain; charset=US-ASCII; format=flowed Mime-Version: 1.0 (Apple Message framework v552) To: internals@lists.php.net Content-Transfer-Encoding: 7bit In-Reply-To: <5.1.0.14.2.20030830155931.0395a758@127.0.0.1> Message-ID: <2627CC60-DAF4-11D7-83A8-000393030CE6@insightbb.com> X-Mailer: Apple Mail (2.552) Subject: References From: LingWitt@insightbb.com References: <5.1.0.14.2.20030830155931.0395a758@127.0.0.1> The current support for references is mediocre at best. For instance: class foobar { var $variable; function foobar() { $variable = "foobar"; } } //This form of new assignment should be the default $a = & new foobar(); $b = & new foobar(); $b->variable = "Hello"; $array = array(&$a, &$b); //The foreach construct uses copies instead of references. foreach ($array as $element) $element->variable = "Hi"; echo $a->variable; //echoes "foobar" echo $b->variable; //echoes "Hello"; //In order for the above to work, a loop is required. for ($i = 0, $count = count($array); $i < $count; $i++) { $element = &$array[$i]; //shown explicitly. $element->variable = "Hi"; } echo $a->variable; //echoes "Hi" echo $b->variable; //echoes "Hi"; //Variable args are always copies, Function foo() { $args = func_get_args() //even loop doesn't work: for ($i = 0, $count = count($args); $i < $count; $i++) { $element = &$args[$i]; $element->variable = "Hello"; } } foo(&$a, &$b); echo $a->variable; //echoes "Hi" echo $b->variable; //echoes "Hi"; Thanks for your time, LingWitt@insightbb.com