Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in /home2/itechies/public_html/dev/template2.php on line 204
How can I check if a variable is defined? :
Ultra fast cheap  linux and windows hosting
    Search code samples  
 
  Keyword
 
 
 
   
 
 
  Code Samples
 
ASP
CSS
Dhtml
Html
Javascript
PHP
 
   
    's Home
 
 
Add faq
View faq
Modify Entry
Modify Profile
Change Password

Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in /home2/itechies/public_html/dev/faq_left_inc.php on line 169
Subscribe
Logout
 
   
 
 

PHP >> General

How can I check if a variable is defined?

Visitor Ratings (11) :

Description
Example:

if (isset($var)) {
echo "the var is set, and equals $var. It may be empty though.";
}
http://www.php.net/isset

isset() will tell you is a varaible has been defined. This can bite some
users, because it will return true even if the varable has an empty
value. Look at empty() as well. Sometimes you'll want to use one rather
than the other. Note that even "0" and 0 are considered empty.

http://www.php.net/empty

For example, say I have an HTML form that passes various form
elements. Even when a user leaves one blank, the variable is still be
set, so isset() will return true. empty() will also return true as
it's empty, even though it's set. But also note that since PHP 4, if
someone enters in the value 0 into a form, it's also seen as empty.

For a useful type comparisons chart of isset() vs empty() vs many other
functions and syntax, see this appendix:

http://www.php.net/manual/en/types.comparisons.php
Code
Select All
 Rate this Resource
 
Home    Blog    Ajax    CSS    Hot scripts    Tips & Tricks    Webmaster Resources     Freelance jobs    Articles    Sitemap    Website builder and Cheap domain names    Lotus Notes FAQ    Our partners