|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2015-04-17 15:40 UTC] spam2 at rhsoft dot net
Description:
------------
since isset() returns false in case a variable contains NULL (which is a major design error) is_null() MUST not throw a warning in case of a undefined variable
Test script:
---------------
<?php
if(isset($nicht_definiert) || is_null($nicht_definiert))
{
echo "defined\n";
}
?>
Expected result:
----------------
no warning or a sane isset() behavior with sanity in mind
how the hell do you test if a variable is defined with the isset() behavior saying no if the value is NULL
Actual result:
--------------
Notice: Undefined variable: nicht_definiert in /mnt/data/downloads/test.php on line 2
defined
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Oct 25 22:00:01 2025 UTC |
bullshit - isset() don't work when a variable is defined and contains NULL, you should read your own documentation [harry@srv-rhsoft:/mnt/data/downloads]$ php test.php [harry@srv-rhsoft:/mnt/data/downloads]$ cat test.php <?php $x = NULL; if(isset($x)) { echo "defined\n"; } ?>> it exists so you can write isset($array['key']) but it don't work relieable because in case of the key existing but NULL as value it gives back false which is pure bullshit - frankly speaking my breath was away as your answers implied isset() in case of a array-key and a simple variable again behaves different, at least that is not the case - it's the same way wrong [harry@srv-rhsoft:~]$ cat test.php <?php $x = array(); $x['a'] = NULL; if(isset($x['a'])) { echo "DEFINED\n"; } else { echo "UNDEFINED\n"; } $y = NULL; if(isset($y)) { echo "DEFNINED\n"; } else { echo "UNDEFINED\n"; }> since an uninitialised variable is considered to > have the value null, a variable set to null is > considered the same as one which hasn't been > initialised. This is consistent bullshit - how can the behavior below callend consistent and how can anything you said above be true with that braindead behavior throwing a warning in once case when you pretend a unitialized variable has the value NULL [harry@srv-rhsoft:/mnt/data/downloads]$ php test.php NULL Notice: Undefined variable: y in /mnt/data/downloads/test.php on line 7 NULL [harry@srv-rhsoft:/mnt/data/downloads]$ cat test.php <?php $x = NULL; if(is_null($x)) { echo "NULL\n"; } if(is_null($y)) { echo "NULL\n"; } ?>