#4281 [Com]: cannot use a referenced argument with defaulting

From: Date: Wed, 21 May 2003 10:24:46 +0000
Subject: #4281 [Com]: cannot use a referenced argument with defaulting
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-40124@lists.php.net to get a copy of this message
ID: 4281 Comment by: sailormax at inbox dot lv Reported By: andy at qabobala dot xapnet dot com Status: Closed Bug Type: Scripting Engine problem Operating System: Linux 2.2.14 PHP Version: 4.0 Beta 4 New Comment: I need take argument-reference, but not obligatory. I write: --------------------- function foo($arg = '') { ... } foo(&$zz); // or foo() --------------------- and have warning: Call-time pass-by-reference has been deprecated... in documentation wrote: ~~~~~~~~~~~~~~~~~~~~~~~ Whether to enable the ability to force arguments to be passed by reference at function call time. This method is deprecated and is likely to be unsupported in future versions of PHP/Zend. ~~~~~~~~~~~~~~~~~~~~~~ And how I can now realize not obligatory argument-reference? Previous Comments: ------------------------------------------------------------------------ [2000-07-04 16:05:54] stas at cvs dot php dot net Yes you cannot use defaults for reference. I am not sure this is possible at all in PHP. Initializer should eb a constant, while reference parameter should be modifiable. ------------------------------------------------------------------------ [2000-04-30 03:36:01] andy at qabobala dot xapnet dot com You cant use a reference with a default value (an optional function arg) when defining a function-- the parser will choke on this. function ($somearg, &$object_ref = 0) { if($object_ref == 0) { ... } else { ... } } Maybe this fails because php needs a predefined NULL - which is a reference to the NULL object. later... ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=4281&edit=1

« previous php.bugs (#40124) next »