#38355 [Opn->Bgs]: @ operator prevents 'Only variables can be passed by reference' error

From: Date: Sun, 06 Aug 2006 13:02:25 +0000
Subject: #38355 [Opn->Bgs]: @ operator prevents 'Only variables can be passed by reference' error
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-100417@lists.php.net to get a copy of this message
ID: 38355 Updated by: helly@php.net Reported By: dima at snaiper dot no-ip dot com -Status: Open +Status: Bogus Bug Type: Scripting Engine problem Operating System: Windows XP PHP Version: 5.1.4 New Comment: Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://www.php.net/manual/ and the instructions on how to report a bug at http://bugs.php.net/how-to-report.php You need to use the @ where the error happens. Here it is the passing to the function or in other words the function call and not the access: php -r 'function test(& $a) {} $b="hello"; @test($b[0]);' Previous Comments: ------------------------------------------------------------------------ [2006-08-06 12:52:17] dima at snaiper dot no-ip dot com Description: ------------ @ in argument passed into function prevents 'Fatal error: Only variables can be passed by reference' error. Reproduce code: --------------- function test(& $a) { echo $a; } $b = "hello"; test($b); // hello test($b[0]); // 'Fatal error: Only variables can be passed by reference' test(@ $b[0]); // h Expected result: ---------------- 'Fatal error: Only variables can be passed by reference' Actual result: -------------- test(@ $b[0]); // h ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=38355&edit=1

« previous php.bugs (#100417) next »