I can't seem to reproduce this bug, I was wondering if anyone has any input they could give me....
I wrote a function to return a parameter by reference that worked with PHP5.0 RC1, looks like this:
function & getParameter ($name)
{
if (isset($this->params[$name]))
{
return $this->params[$name];
}
return NULL;
}
Now I recently upgraded to PHP5.0.2 and I get errors. I have tried to make a test case script to demonstrate it but it works fine in command line. My cgi script is huge, so I can't tell you how to reproduce it, but it's giving me this error: "Only variable references should be returned by reference " on the line with "return NULL;".
Could this be related to another bug? The code works fine if I replace "return NULL" with anything else, even "return $nonexistant->variable;". Is there a way I can turn this check off?
-Jeff Moss
return NULL;
... snip ...
"Only variable references should be returned by reference "
Just like the error message says. "References" are referring to
variables. NULL
isn't a variable. Do this instead:
$tmp = null;
return $tmp;
--Dan
--
T H E A N A L Y S I S A N D S O L U T I O N S C O M P A N Y
data intensive web and database programming
http://www.AnalysisAndSolutions.com/
4015 7th Ave #4, Brooklyn NY 11232 v: 718-854-0335 f: 718-854-0409
Well I can't reliably reproduce it, is this expected behavior or not? If
there is a cleaner solution I'd like to try that first.
I'd like to turn off this error altogether even if I have to patch and
recompile. I can't see anything like this in the changelogs. Since when
should anything not be allowed to return null?
-Jeff
----- Original Message -----
From: "Daniel Convissor" danielc@analysisandsolutions.com
To: "Jeffrey Moss" jeff@opendbms.com
Cc: internals@lists.php.net
Sent: Monday, September 27, 2004 12:04 PM
Subject: Re: [PHP-DEV] return NULL
by reference
return NULL;
... snip ...
"Only variable references should be returned by reference "
Just like the error message says. "References" are referring to
variables.NULL
isn't a variable. Do this instead:$tmp = null; return $tmp;
--Dan
--
T H E A N A L Y S I S A N D S O L U T I O N S C O M P A N Y
data intensive web and database programming
http://www.AnalysisAndSolutions.com/
4015 7th Ave #4, Brooklyn NY 11232 v: 718-854-0335 f: 718-854-0409
Daniel Convissor wrote:
return NULL;
... snip ...
"Only variable references should be returned by reference "
Just like the error message says. "References" are referring to
variables.NULL
isn't a variable. Do this instead:$tmp = null; return $tmp;
i thought that one was fixed?
regards,
Lukas
return NULL;
... snip ...
"Only variable references should be returned by reference "
Just like the error message says. "References" are referring to
variables.NULL
isn't a variable. Do this instead:$tmp = null; return $tmp;
Although this is a totally stupid thing to do.
Derick