From:
Operating system:
PHP version: 5.3.2
Package: *General Issues
Bug Type: Feature/Change Request
Bug description:Calculate expression before using it as argument
Description:
------------
Calculate expression before using it as argument in function and with echo.
Test script:
---------------
class p{
protected $_name = null;
protected $_value = null;
public function __construct($name, $value){
$this->_name = $name;
$this->_value = $value;
}
public function is($value){
$this->_value = $value;
return $this;
}
public function __toString(){
return "$this->_name = $this->_value";
}
}
class a{
protected $_a = null;
public function __set($name, $value){
$this->_a[$name] = new p($name, $value);
return $this->_a[$name];
}
public function __get($name){
if (!isset($this->_a[$name])){
$this->_a[$name] = new p($name, null);
}
return $this->_a[$name];
}
}
class q{
public function where($var){
echo $var;
}
}
$a = new a();
echo $a->x = 2; // "2" (Expected: "x = 2")
echo "\r\n";
echo $a->x; // "x = 2"
echo "\r\n";
$q = new q();
$q->where($a->x = 2); // "2" (Expected: "x = 2")
echo "\r\n";
$q->where(($a->x = 2)); // "2" (Expected: "x = 2")
Expected result:
----------------
x = 2
x = 2
x = 2
x = 2
Actual result:
--------------
2
x = 2
2
2
--
Edit bug report at http://bugs.php.net/bug.php?id=51280&edit=1
--
Try a snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=51280&r=trysnapshot52
Try a snapshot (PHP 5.3):
http://bugs.php.net/fix.php?id=51280&r=trysnapshot53
Try a snapshot (PHP 6.0):
http://bugs.php.net/fix.php?id=51280&r=trysnapshot60
Fixed in SVN:
http://bugs.php.net/fix.php?id=51280&r=fixed
Fixed in SVN and need be documented:
http://bugs.php.net/fix.php?id=51280&r=needdocs
Fixed in release:
http://bugs.php.net/fix.php?id=51280&r=alreadyfixed
Need backtrace:
http://bugs.php.net/fix.php?id=51280&r=needtrace
Need Reproduce Script:
http://bugs.php.net/fix.php?id=51280&r=needscript
Try newer version:
http://bugs.php.net/fix.php?id=51280&r=oldversion
Not developer issue:
http://bugs.php.net/fix.php?id=51280&r=support
Expected behavior:
http://bugs.php.net/fix.php?id=51280&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=51280&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=51280&r=submittedtwice
register_globals:
http://bugs.php.net/fix.php?id=51280&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=51280&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=51280&r=dst
IIS Stability:
http://bugs.php.net/fix.php?id=51280&r=isapi
Install GNU Sed:
http://bugs.php.net/fix.php?id=51280&r=gnused
Floating point limitations:
http://bugs.php.net/fix.php?id=51280&r=float
No Zend Extensions:
http://bugs.php.net/fix.php?id=51280&r=nozend
MySQL Configuration Error:
http://bugs.php.net/fix.php?id=51280&r=mysqlcfg