Bug #55278 [Opn->Dup]: @ Error control operator prevents creation of variable
Edit report at https://bugs.php.net/bug.php?id=55278&edit=1
ID: 55278
Updated by: laruence@php.net
Reported by: lucas at threeamdesign dot com
Summary: @ Error control operator prevents creation of
variable
-Status: Open
+Status: Duplicate
Type: Bug
Package: Scripting Engine problem
Operating System: Windows 7
PHP Version: 5.3.6
Block user comment: N
Private report: N
New Comment:
this is a duplicate, see #47623
Previous Comments:
------------------------------------------------------------------------
[2011-07-25 03:22:23] lucas at threeamdesign dot com
Description:
------------
When a function is defined with a parameter that is passed by reference, calling the function with a
variable that has not been previously set will create that variable (and trigger a warning). After
the function is called that variable exists (won't trigger warnings) and holds null or whatever
value the function assigned to it.
If you try to suppress the warning for the variable that doesn't exist at call time, it will
not be created, and trying to access it after the function triggers warnings.
It works as expected if you suppress errors on the function call but this is not desirable because
it will also hide other errors.
Test script:
---------------
<?php
function foo(&$bar) {
$bar = 'woo';
}
@foo($x);
foo(@$y);
var_dump($x, $y);
Expected result:
----------------
string(3) "woo"
string(3) "woo"
Actual result:
--------------
Notice: Undefined variable: y in FILE on line LINE
string(3) "woo"
NULL
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=55278&edit=1
Thread (4 messages)