On Thu, 2003-08-14 at 12:59, Ilia Alshanetsky wrote: > On August 14, 2003 03:33 pm, Robert Cummings wrote: > > Actually isset() doesn't behave as it should: > > > > $foo = null; > > echo isset( $foo ); > > Not quite. To understand the nature of NULL you must consider the following. > Suppose you have a variable $foo you wish to 'destroy' you can do so by doing > unset($foo) or $foo = NULL;. In both cases the value of $foo will be > destroyed, however the variable will remain, it's value will become NULL. > Therefor isset() behaviour, which works by seeing if a variable exists and > making sure that its value is not null, is correct and now flawed as you > claim. This is true for other languages as well such as C, when a pointer's > value is null that pointer is 'no set'. > > Ilia
unset($foo) is not the same as $foo = NULL, which is one way this is useful: <?php echo "\$foo = null\n\n"; $foo = null; echo "variable_exists(\$foo): " . (variable_exists($foo) ? 'yes' : 'no') . " (should be yes)\n"; echo "isset(\$foo): " . (isset($foo) ? 'yes' : 'no') . " (should be yes)\n"; echo "unset(\$foo);\n"; unset($foo); echo "variable_exists(\$foo): " . (variable_exists($foo) ? 'yes' : 'no') . " (should be no)\n"; echo "isset(\$bar): " . (isset($bar) ? 'yes' : 'no') . " (should be no)\n"; ?> OUTPUT: $foo = null variable_exists($foo): yes (should be yes) isset($foo): no (should be yes) unset($foo); variable_exists($foo): no (should be no) isset($bar): no (should be no) -- Torben Wilson <[EMAIL PROTECTED]> +1.604.709.0506 http://www.thebuttlesschaps.com http://www.inflatableeye.com http://www.hybrid17.com http://www.themainonmain.com -----==== Boycott Starbucks! http://www.haidabuckscafe.com ====----- -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php