# return NULL by reference

- Thread: https://externals.io/message/13017
- Original archive: https://news-web.php.net/php.internals/13017
- Started by Jeffrey Moss on 2004-09-27T17:52:24+00:00
- Messages: 5
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #13017 — Jeffrey Moss — 2004-09-27T17:52:24+00:00

URL: https://externals.io/message/13017#13017

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

---

## #13019 — Daniel Convissor — 2004-09-27T18:04:57+00:00

URL: https://externals.io/message/13017#13019 · In reply to: #13017

>         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

---

## #13021 — Jeffrey Moss — 2004-09-27T18:33:54+00:00

URL: https://externals.io/message/13017#13021 · In reply to: #13019

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


> 
>
> > […]
> ... snip ...
> > […]
>
> 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

---

## #13024 — Lukas Smith — 2004-09-27T18:39:46+00:00

URL: https://externals.io/message/13017#13024 · In reply to: #13019

Daniel Convissor wrote:
> 
> 
> 
> > […]
> 
> ... snip ...
> 
> > […]
> 
> 
> 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

---

## #13025 — Derick Rethans — 2004-09-27T18:40:17+00:00

URL: https://externals.io/message/13017#13025 · In reply to: #13019

> 
>
> > […]
> ... snip ...
> > […]
>
> 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
