#44313 [Opn]: inconsistencies in property assignation on scalar variables
| From: | felipe@php.net | Date: | Sun, 02 Mar 2008 21:33:08 +0000 |
| Subject: | #44313 [Opn]: inconsistencies in property assignation on scalar variables | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-122845@lists.php.net to get a copy of this message | ||
ID: 44313
Updated by: felipe@php.net
Reported By: johann dot queuniet at gmail dot com
Status: Open
Bug Type: Class/Object related
Operating System: All
PHP Version: 5.2.5
New Comment:
Using E_STRICT, "Strict Standards: Creating default object from empty
value" are showed for other cases.
Previous Comments:
------------------------------------------------------------------------
[2008-03-02 18:19:19] johann dot queuniet at gmail dot com
Description:
------------
The way PHP handles property assignation on scalar variables evaluating
as false is inconsistent.
Reproduce code:
---------------
<?php
$var1->test = true;
$var2 = null;
$var2->test = true;
$var3 = false;
$var3->test = true;
$var3 = '';
$var3->test = true;
$var4 = 0;
$var4->test = true;
$var5 = '0';
$var5->test = true;
$var6 = array();
$var6->test = true;
?>
Expected result:
----------------
PHP should handle every case the same way, with a "Warning: Attempt to
assign property of non-object". The first line should also trigger a
notice since the $var1 variable is undeclared.
Actual result:
--------------
PHP behaves as with arrays and only triggers a warning for the last
three. The other lines create an stdClass object with the test property
set.
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=44313&edit=1