PHP7 NULL



  • Is that just me? Or am I doing something wrong?

    <?php
    $arr = [];
    $arr['key'] = NULL;
    

    var_dump(isset($arr['key']));
    //bool(false)

    var_dump(is_null($arr['key']));
    //bool(true)

    var_dump(is_null($arr['any_key']));
    //bool(true)

    How do you check the key?



  • If you read the documentation, you'll see that it'sset checks not only the existence of a variable, but also its conformity null if it exists, it's the most inaccuracies of the PHP they all say. In the remaining cases, PHP conduct requires that at least something be returned to it by a non-existent key (possibly throwing a warning) and that value is null.

    To determine the key in the mass, you can use the function. http://php.net/manual/en/function.array-key-exists.php ♪


Log in to reply
 


Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2