From 918600ab1dfac6115669a8884ffaf233c543c595 Mon Sep 17 00:00:00 2001 From: Philip Olson Date: Sat, 16 Nov 2002 07:54:03 +0000 Subject: [PATCH] Note: isset only takes on variables. Closes bug #20454 Also using var_dump() instead of print in examples. Expanded examples a bit. git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@104406 c90b9560-bf6c-de11-be94-00142212c4b1 --- reference/var/functions/isset.xml | 55 +++++++++++++++++++++++-------- 1 file changed, 41 insertions(+), 14 deletions(-) diff --git a/reference/var/functions/isset.xml b/reference/var/functions/isset.xml index d07bfddeac..e4c296dcc2 100644 --- a/reference/var/functions/isset.xml +++ b/reference/var/functions/isset.xml @@ -1,5 +1,5 @@ - + @@ -28,22 +28,44 @@ return &false; if testing a variable that has been set to &null;. Also note that a &null; byte ("\0") is not equivalent to the PHP &null; constant. + + + Warning + + isset only works with variables as passing anything + else will result in a parse error. + + + ]]> @@ -55,12 +77,17 @@ $foo = NULL; 1, 'hello' => null); - echo isset ($a['test']); // TRUE - echo isset ($a['foo']); // FALSE - echo isset ($a['hello']); // FALSE - echo array_key_exists('hello', $a); // TRUE +$a = array ('test' => 1, 'hello' => NULL); + +var_dump( isset ($a['test']) ); // TRUE +var_dump( isset ($a['foo']) ); // FALSE +var_dump( isset ($a['hello']) ); // FALSE + +// The key 'hello' equals NULL so is considered unset +// If you want to check for NULL key values then try: +var_dump( array_key_exists('hello', $a) ); // TRUE + ?> ]]>