Req #60944 [Opn]: Unable to detect if variable exists vs. is null
| From: | laruence@php.net | Date: | Wed, 01 Feb 2012 09:54:15 +0000 |
| Subject: | Req #60944 [Opn]: Unable to detect if variable exists vs. is null | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-167027@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=60944&edit=1
ID: 60944
Updated by: laruence@php.net
Reported by: lampacz+php at gmail dot com
Summary: Unable to detect if variable exists vs. is null
Status: Open
Type: Feature/Change Request
Package: Variables related
Operating System: Linux
PHP Version: 5.3.9
Block user comment: N
Private report: N
New Comment:
<?php
$a = null;
var_dump(array_key_exists('a', get_defined_vars())); //or $GLOBALS
?>
Previous Comments:
------------------------------------------------------------------------
[2012-02-01 08:05:10] lampacz+php at gmail dot com
Description:
------------
There is no difference between $x = NULL and unset($a). So i'm unable to detect if variable was
defined (so it can be defined and be filled with null)
http://www.php.net/manual/en/types.comparisons.php
Table Comparisons of $x with PHP functions, rows 2 - 4 gives same results
Expected result:
----------------
Different results for undefined variables and null variables
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=60944&edit=1