From:             robin_fernandes at uk dot ibm dot com
Operating system: Windows
PHP version:      5.2.5
PHP Bug Type:     Scripting Engine problem
Bug description:  Extra parentheses prevent implicit variable initialisation 
when passing by ref

Description:
------------
Passing an undefined variable by reference causes that variable to be
implicitly defined. However, this is not the case if the argument is inside
parentheses. 

This is reproducible on php5.2.5 as well as php5.3 and php6 snaps.



Reproduce code:
---------------
<?php
function f(&$ref) {
  $ref='changed';
}

echo "Pass undefined variable by ref:\n";
f( $a );
var_dump($a);

echo "\nPass undefined variable by ref with parentheses:\n";
f( ($b) );
var_dump($b);
?>


Expected result:
----------------
Pass undefined variable by ref:
string(7) "changed"

Pass undefined variable by ref with parentheses:
string(7) "changed"

Actual result:
--------------
Pass undefined variable by ref:
string(7) "changed"

Pass undefined variable by ref with parentheses:

Notice: Undefined variable: b in %s on line 11

Strict Standards: Only variables should be passed by reference in %s on
line 11

Notice: Undefined variable: b in %s on line 12
NULL


-- 
Edit bug report at http://bugs.php.net/?id=43984&edit=1
-- 
Try a CVS snapshot (PHP 4.4): 
http://bugs.php.net/fix.php?id=43984&r=trysnapshot44
Try a CVS snapshot (PHP 5.2): 
http://bugs.php.net/fix.php?id=43984&r=trysnapshot52
Try a CVS snapshot (PHP 5.3): 
http://bugs.php.net/fix.php?id=43984&r=trysnapshot53
Try a CVS snapshot (PHP 6.0): 
http://bugs.php.net/fix.php?id=43984&r=trysnapshot60
Fixed in CVS:                 http://bugs.php.net/fix.php?id=43984&r=fixedcvs
Fixed in release:             
http://bugs.php.net/fix.php?id=43984&r=alreadyfixed
Need backtrace:               http://bugs.php.net/fix.php?id=43984&r=needtrace
Need Reproduce Script:        http://bugs.php.net/fix.php?id=43984&r=needscript
Try newer version:            http://bugs.php.net/fix.php?id=43984&r=oldversion
Not developer issue:          http://bugs.php.net/fix.php?id=43984&r=support
Expected behavior:            http://bugs.php.net/fix.php?id=43984&r=notwrong
Not enough info:              
http://bugs.php.net/fix.php?id=43984&r=notenoughinfo
Submitted twice:              
http://bugs.php.net/fix.php?id=43984&r=submittedtwice
register_globals:             http://bugs.php.net/fix.php?id=43984&r=globals
PHP 3 support discontinued:   http://bugs.php.net/fix.php?id=43984&r=php3
Daylight Savings:             http://bugs.php.net/fix.php?id=43984&r=dst
IIS Stability:                http://bugs.php.net/fix.php?id=43984&r=isapi
Install GNU Sed:              http://bugs.php.net/fix.php?id=43984&r=gnused
Floating point limitations:   http://bugs.php.net/fix.php?id=43984&r=float
No Zend Extensions:           http://bugs.php.net/fix.php?id=43984&r=nozend
MySQL Configuration Error:    http://bugs.php.net/fix.php?id=43984&r=mysqlcfg

Reply via email to