philip Sat Nov 16 02:54:03 2002 EDT
Modified files:
/phpdoc/en/reference/var/functions isset.xml
Log:
Note: isset only takes on variables. Closes bug #20454
Also using var_dump() instead of print in examples. Expanded examples a bit.
Index: phpdoc/en/reference/var/functions/isset.xml
diff -u phpdoc/en/reference/var/functions/isset.xml:1.5
phpdoc/en/reference/var/functions/isset.xml:1.6
--- phpdoc/en/reference/var/functions/isset.xml:1.5 Sat Jun 1 12:33:45 2002
+++ phpdoc/en/reference/var/functions/isset.xml Sat Nov 16 02:54:03 2002
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.5 $ -->
+<!-- $Revision: 1.6 $ -->
<!-- splitted from ./en/functions/var.xml, last change in rev 1.2 -->
<refentry id="function.isset">
<refnamediv>
@@ -28,22 +28,44 @@
return &false; if testing a variable that has been set to &null;. Also
note that a &null; byte (<literal>"\0"</literal>) is not equivalent to
the PHP &null; constant.
+ </para>
+ <note>
+ <title>Warning</title>
+ <para>
+ <function>isset</function> only works with variables as passing anything
+ else will result in a parse error.
+ </para>
+ </note>
+ <para>
<informalexample>
<programlisting role="php">
<![CDATA[
<?php
- $a = "test";
- $b = "anothertest";
- echo isset ($a); // TRUE
- echo isset ($a, $b); //TRUE
+$var = '';
+
+// This will evaluate to &true; so the text will be printed.
+if (isset($var)) {
+ print "This var is set set so I will print.";
+}
+
+// In the next examples we'll use var_dump to output
+// the return value of isset().
- unset ($a);
- echo isset ($a); // FALSE
- echo isset ($a, $b); //FALSE
+$a = "test";
+$b = "anothertest";
+
+var_dump( isset($a) ); // TRUE
+var_dump( isset ($a, $b) ); // TRUE
+
+unset ($a);
+
+var_dump( isset ($a) ); // FALSE
+var_dump( isset ($a, $b) ); // FALSE
$foo = NULL;
- print isset ($foo); // FALSE
+var_dump( isset ($foo) ); // FALSE
+
?>
]]>
</programlisting>
@@ -55,12 +77,17 @@
<programlisting role="php">
<![CDATA[
<?php
- $a = array ('test' => 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
+
?>
]]>
</programlisting>
--
PHP Documentation Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php