note 30018 added to language.variables

From: Date: Tue, 04 Mar 2003 12:03:42 +0000
Subject: note 30018 added to language.variables
Groups: php.notes 
Request: Send a blank email to php-notes+get-44823@lists.php.net to get a copy of this message
php shows up a var-name conflict if you use the same name for scalar values and arrays: first we want to use a scalar value: $scalarValue = 5; scalarValue holds: 5 But than, you want to use the same name for an array, too, which seems ok at first glimps: (sometimes, its hard to find new names for the same purpose..) $scalarValue = array(); array_push($scalarValue,3); scalarValue[0] holds: 3 now, all seems ok, since the array assignment went well.. but, where is the scalarValue gone, if we ask for it? if you echo for it, you ask for the array: scalarValue holds: $Array The scalar value has no longer a reference, since it shares the same name with an array.. such a bug can give you some hard time to dig for! -- http://www.php.net/manual/en/language.variables.php http://master.php.net/manage/user-notes.php?action=edit+30018 http://master.php.net/manage/user-notes.php?action=delete+30018 http://master.php.net/manage/user-notes.php?action=reject+30018

« previous php.notes (#44823) next »