PHP 4.0 Bug #7890 Updated: Recursion problem with isset and unset

From: Date: Mon, 20 Nov 2000 13:00:18 +0000
Subject: PHP 4.0 Bug #7890 Updated: Recursion problem with isset and unset
Groups: php.dev 
Request: Send a blank email to php-dev+get-38591@lists.php.net to get a copy of this message
ID: 7890 Updated by: hholzgra Reported By: nickj@ihug.com.au Status: Closed Bug Type: Scripting Engine problem Assigned To: Comments: 'global $test' creates a reference to $GLOBALS['test'] and 'unset($test)' will only unset this reference you have to write 'unset($GLOBALS['test']) to unset the variable in the global scope Previous Comments: --------------------------------------------------------------------------- [2000-11-20 06:58:44] nickj@ihug.com.au I have a problem with a recursive function call that does not work as I would expect. A short script that reproduces the problem is: <?php function fn() { global $test; if (isset($test)) { print "test is set<br>n"; unset($test); fn(); } else { print "test is NOT set<br>n"; } } $test = array("exam_id" => "MATH_101", "exam_code" => "Mathematics Intro"); fn(); ?> What Happens: - out produced is: test is set test is set test is set test is set test is set test is set ... [and so on] ... What I would expect to happen - looking for this output: test is set test is NOT set [end of output] Setup Information: Configure command from phpinfo() gives: "'./configure' '--with-apxs=/usr/sbin/apxs' '--without-mysql' '--disable-static' '--disable-debug' '--enable-pic' '--enable-inline-optimization' '--prefix=/usr' '--with-zlib' '--with-config-file-path=/etc' '--enable-magic-quotes' '--enable-debugger' '--enable-track-vars' '--enable-safe-mode' '--with-exec-dir=/usr/bin' '--with-regex=system' '--with-versioning' '--enable-dba=shared' '--with-gdbm' '--with-db2' '--enable-sysvsem' '--enable-sysvshm' '--with-mod_charset' '--enable-force-cgi-redirect' '--with-mm' '--enable-trans-sid' '--with-dbase' '--with-filepro' '--enable-yp' '--enable-ftp' '--with-xml' '--with-gettext'" Also using Zend engine (don't know if this is relevant) : "This program makes use of the Zend scripting language engine: Zend Engine v1.0.3, Copyright (c) 1998-2000 Zend Technologies with Zend Optimizer v0.99, Copyright (c) 1998-2000, by Zend Technologies" Any other information I can supply that would assist, just email me and let me know. Of course, it could just be something obviously and embarrassingly wrong in the code above, but if it is, I honestly can't see it. Cheers, Nick. --------------------------------------------------------------------------- Full Bug description available at: http://bugs.php.net/?id=7890

« previous php.dev (#38591) next »