#24421 [NEW]: global $$var doesnt work as expected

From: Date: Mon, 30 Jun 2003 19:32:10 +0000
Subject: #24421 [NEW]: global $$var doesnt work as expected
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-42911@lists.php.net to get a copy of this message
From: humillo at hotmail dot com Operating system: linux 2.4.20 PHP version: 5.0.0b1 (beta1) PHP Bug Type: Variables related Bug description: global $$var doesnt work as expected Description: ------------ The global variable isnt being assigned the mysql connection resource id. This worked fine with PHP3 and 4. Notes: * Ive noticed that using anything like: $$varname = "GOODBYE"; ... assigns correctly, only with mysql_connect() the assignment is ignored. * If you remove the global declaration and use: $GLOBALS[$varname] = mysql_connect(); .. it works. Reproduce code: --------------- <?php function checkme($varname = 'var') { global $$varname; $$varname = mysql_connect("your", "data", "here"); } $var = 'HELLO'; checkme(); echo $var; // Should be a resource_id, but its "HELLO" ?> Expected result: ---------------- Resource Id #<something> Actual result: -------------- HELLO -- Edit bug report at http://bugs.php.net/?id=24421&edit=1 -- Try a CVS snapshot: http://bugs.php.net/fix.php?id=24421&r=trysnapshot Fixed in CVS: http://bugs.php.net/fix.php?id=24421&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=24421&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=24421&r=needtrace Try newer version: http://bugs.php.net/fix.php?id=24421&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=24421&r=support Expected behavior: http://bugs.php.net/fix.php?id=24421&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=24421&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=24421&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=24421&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=24421&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=24421&r=dst IIS Stability: http://bugs.php.net/fix.php?id=24421&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=24421&r=gnused

« previous php.bugs (#42911) next »