php function Isset () can only be used for variable _php tutorials

Source: Internet
Author: User
Through the

Format: bool Isset (mixed var [, mixed Var [, ...])

Function: Detect whether the variable is set

return value:

Returns FALSE if the variable does not exist
Returns FALSE if the variable exists and its value is null
Returns TURE if the variable exists and the value is not NULL

Returns TRUE if each item meets the previous requirement when checking multiple variables at the same time, otherwise the result is FALSE

Version: PHP 3, PHP 4, PHP 5

More information:

After you use Unset () to release a variable, it will no longer be isset ().
PHP functions Isset () can only be used for variables, and passing any other parameter will result in parsing errors.
Detects if a constant is set to use the defined () function.

 
 
  1. < ? PHP
  2. $ var = '' ;
  3. if (Isset ($var))//null value, 0, False
    The assignment result is isset to TRUE, so behind
    The text will be printed out.
  4. print "Blank value- > isset = true. ";
  5. $ var = NULL ; if (!isset ($var))//
    Null will be isset sentenced to FALSE
  6. print "NULL value- > isset = false. ";
    The following uses the return value of the Var_dump output isset ().
  7. $ a = "Test" ;
  8. $ b = "Anothertest" ;
  9. Var_dump (Isset ($a)); TRUE
  10. Var_dump (Isset ($a, $b)); TRUE
  11. unset ($a);
  12. Var_dump (Isset ($a)); FALSE
  13. Var_dump (Isset ($a, $b)); FALSE
  14. ?>

The PHP function Isset () also applies to the checking of array elements and object elements. If an array or object instance is not defined, the array element/object element detected in it will be returned false.

 
  
  
  1. < ? PHP
  2. $ a Array (' Test ' => 1, ' hello ' => NULL);
  3. Var_dump (isset ($a [' Test ']); TRUE
  4. Var_dump (isset ($a [' foo ']); FALSE
  5. Var_dump (isset ($a [' hello ']); FALSE
  6. The value of the key ' hello ' is equal to NULL, so it is considered to be an unassigned value.
  7. If you want to detect NULL key values, you can try the methods below.
  8. Var_dump (array_key_exists (' hello ', $a)); TRUE
  9. ?>

Note: Since this is a language structure and not a function, PHP function isset () cannot be called by a variable function.


http://www.bkjia.com/PHPjc/445983.html www.bkjia.com true http://www.bkjia.com/PHPjc/445983.html techarticle by the format: bool Isset (mixed var [, mixed Var [, ...]) function: Detects if the variable has a return value: If the variable does not exist, it returns FALSE if the variable exists and its value is NULL, also ...

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.