ID:               43984
 Updated by:       [EMAIL PROTECTED]
 Reported By:      robin_fernandes at uk dot ibm dot com
-Status:           Open
+Status:           Bogus
 Bug Type:         Scripting Engine problem
 Operating System: Windows
 PHP Version:      5.2.5
 New Comment:

Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions.  Due to the volume
of reports we can not explain in detail here why your report is not
a bug.  The support channels will be able to provide an explanation
for you.

Thank you for your interest in PHP.

You're passing an expression "($b)" as a variable. An expression is not
a variable. For this to work, you need to pass a variable only "$b".


Previous Comments:
------------------------------------------------------------------------

[2008-01-30 18:01:27] robin_fernandes at uk dot ibm dot com

Note that if the variable is defined, it is correctly passed by
reference whether or not the parens are present:

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

echo "\nPass defined variable by ref with parentheses:\n";
$c = null;
f( ($c) );
var_dump($c);
?>

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

------------------------------------------------------------------------

[2008-01-30 18:00:49] robin_fernandes at uk dot ibm dot com

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 this bug report at http://bugs.php.net/?id=43984&edit=1

Reply via email to