PhpDig.net

What is PhpDig?
PhpDig is a PHP MySQL based
Web Spider & Search Engine.




isset

Name

isset — Tests whether a variable is set.

Synopsis

bool isset(variable);
mixed variable: Variable to test

Returns

TRUE if the variable contains a value other than NULL; FALSE otherwise

Description

isset() is used to check whether a variable is currently set.

Note

If the variable contains a null value NULL), isset() returnsFALSE. Note that a null byte ("\0") is not equivalent to the PHP constant NULL. If a variable contains only a null byte ("\0"), it is still considered to be set.

Also note that isset() cannot be used on a literal (such as 10, "A string", and so on) - see the example.

Version

PHP Version: 3+, 4+

See also

empty()

Example

Example 1401. Demonstrate how isset() works

<pre>
<?
$greeting = "Hi!";

if (isset ($value))
    print "\$greeting is set.\n";
else
    print "\$greeting is not set.\n";

// This example uses the ternary operator
//... in place of an if/else statement
print isset ($foo) ? '$foo is set' : '$foo is not set' ."\n";

// Variables set to null are considered not to be set
$bar = NULL;
print isset ($bar) ? '$bar is set' : '$bar is not set' ."\n";

// NULL and "\0" are not equivalent
$baz = "\0";
print isset ($bar) ? '$baz is set' : '$baz is not set' ."\n";

// An alternative to calling isset()
print ($var !== NULL) ? '$var is set' : '$var is not set' ."\n";

// Demonstrate incorrect usage of isset()
// If you test this entire example, you must remove or comment the line below
isset ("Hi!");
?>
</pre>



PHP Functions Essential Reference. Copyright © 2002 by New Riders Publishing (Authors: Zak Greant, Graeme Merrall, Torben Wilson, Brett Michlitsch). This material may be distributed only subject to the terms and conditions set forth in the Open Publication License, v1.0 or later (the latest version is presently available at http://www.opencontent.org/openpub/). The authors of this book have elected not to choose any options under the OPL. This online book was obtained from http://www.fooassociates.com/phpfer/ and is designed to provide information about the PHP programming language, focusing on PHP version 4.0.4 for the most part. The information is provided on an as-is basis, and no warranty or fitness is implied. All persons and entities shall have neither liability nor responsibility to any person or entity with respect to any loss or damage arising from the information contained in this book.

Powered by: vBulletin Version 3.0.7
Copyright ©2000 - 2005, Jelsoft Enterprises Ltd.
Copyright © 2001 - 2005, ThinkDing LLC. All Rights Reserved.