#31715 [Fbk->NoF]: isset() and empty() return "Trying to get property of non-object"
| From: | php-bugs at lists dot php dot net | Date: | Fri, 04 Feb 2005 00:00:06 +0000 |
| Subject: | #31715 [Fbk->NoF]: isset() and empty() return "Trying to get property of non-object" | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-73430@lists.php.net to get a copy of this message | ||
ID: 31715
Updated by: php-bugs@lists.php.net
Reported By: cryptographite at comcast dot net
-Status: Feedback
+Status: No Feedback
Bug Type: Scripting Engine problem
Operating System: FreeBSD
PHP Version: 5.0.3
New Comment:
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
Previous Comments:
------------------------------------------------------------------------
[2005-01-27 08:12:45] derick@php.net
Please try using this CVS snapshot:
http://snaps.php.net/php5-STABLE-latest.tar.gz
For Windows:
http://snaps.php.net/win32/php5.0-win32-latest.zip
------------------------------------------------------------------------
[2005-01-27 05:38:02] cryptographite at comcast dot net
Description:
------------
Using isset() or empty() on an unset child/parent object throws "Trying
to get property of non-object" errors.
This is contrary to the behavior of PHP 4 and makes no sense given the
purpose of the functions and their descriptions.
isset() and empty() should properly handle querying unset objects for
children without returning errors.
Reproduce code:
---------------
<?php
echo '$not->set->variable' . "\n";
echo isset($not->set->variable) ? 'isset true' : 'isset false';
echo "\n";
echo empty($not->set->variable) ? 'empty true' : 'isset false';
echo "\n------------------\n";
echo '$not->set[$key]' . "\n";
echo isset($not->set[$key]) ? 'isset true' : 'isset false';
echo "\n";
echo empty($not->set[$key]) ? 'empty true' : 'empty false';
echo "\n";
?>
Expected result:
----------------
Expected output: (No error messages)
$not->set->variable
isset false
empty true
------------------
$not->set[$key]
isset false
empty true
Actual result:
--------------
$not->set->variable
PHP Notice: Trying to get property of non-object in - on line 3
Notice: Trying to get property of non-object in - on line 3
isset false
PHP Notice: Trying to get property of non-object in - on line 5
Notice: Trying to get property of non-object in - on line 5
empty true
------------------
$not->set[$key]
PHP Notice: Undefined variable: key in - on line 9
Notice: Undefined variable: key in - on line 9
PHP Notice: Trying to get property of non-object in - on line 9
Notice: Trying to get property of non-object in - on line 9
isset false
PHP Notice: Undefined variable: key in - on line 11
Notice: Undefined variable: key in - on line 11
PHP Notice: Trying to get property of non-object in - on line 11
Notice: Trying to get property of non-object in - on line 11
empty true
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=31715&edit=1