|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2005-01-27 05:38 UTC] 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 PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Dec 07 09:00:02 2025 UTC |
For example: (in view script) <?php $obj = $this->{$index.'_heading1'}; $text = $obj->text; var_dump($text); ?> ends in an error ... on non-object ... <?php $obj = $this->{$index.'_heading1'}; $text = $obj->text; die(var_dump($text)); ?> returns the right string ... this can't be a fail on me =/ ... All objects will be loaded correctly. But if i try to access the object property it fails. Please Email me on solution, i stucking in this problem. Thanks in Advance