# PHP 5.0.3 E_STRICT question - returning NULL from reference returning function

- Thread: https://externals.io/message/15270
- Original archive: https://news-web.php.net/php.internals/15270
- Started by Yermo Lamers on 2005-03-06T04:47:23+00:00
- Messages: 2
- 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

---

## #15270 — Yermo Lamers — 2005-03-06T04:47:23+00:00

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

What is the proper way to return a `NULL` condition from a method that
returns a reference?

function &testfunc()
{
return NULL;
}

generates:

"Strict Standards: Only variable references should be returned by
reference in ..."

Is the correct approach to do something like:

function &testfunc()
{
$nullVar = NULL;
return $nullVar;
}

??

----------------------------------------------------------------------------
DTLink Software                                 http://www.dtlink.com
       Desktop Software and Web Applications

---

## #15272 — Zeev Suraski — 2005-03-06T04:51:18+00:00

URL: https://externals.io/message/15270#15272 · In reply to: #15270

At 06:47 06/03/2005, Yermo Lamers wrote:

>What is the proper way to return a `NULL` condition from a method that
>returns a reference?
>
>function &testfunc()
>{
>return NULL;
>}
>
>generates:
>
>"Strict Standards: Only variable references should be returned by
>reference in ..."
>
>Is the correct approach to do something like:
>
>function &testfunc()
>{
>$nullVar = NULL;
>return $nullVar;
>}

That'd work, yep.

Zeev
