# Improving error messages when using indirect references

- Thread: https://externals.io/message/7804
- Original archive: https://news-web.php.net/php.internals/7804
- Started by Martin Jansen on 2004-02-13T14:38:49+00:00
- Messages: 3
- 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

---

## #7804 — Martin Jansen — 2004-02-13T14:38:49+00:00

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

Hey,

        <?php
        error_reporting(E_ALL);

        echo $$foo;
        ?>

results in 

        Notice: Undefined variable: foo in /foo/bar.php on line 4

        Notice: Undefined variable: in /foo/bar.php on line 4

Wouldn't it be more appropriate if the second notice was something like
"Notice: Undefined variable: <unnamed> in /foo/bar.php on line 4"?

-- 
    - Martin                           Martin Jansen
                            http://martinjansen.com/

---

## #7805 — Hartmut Holzgraefe — 2004-02-13T14:47:08+00:00

URL: https://externals.io/message/7804#7805 · In reply to: #7804

Martin Jansen wrote:
> Hey,
> 
>         <?php
>         error_reporting(E_ALL);
> 
>         echo $$foo;
>         ?>
> 
> results in 
> 
>         Notice: Undefined variable: foo in /foo/bar.php on line 4
> 
>         Notice: Undefined variable: in /foo/bar.php on line 4
> 
> Wouldn't it be more appropriate if the second notice was something like
> "Notice: Undefined variable: <unnamed> in /foo/bar.php on line 4"?
> 

i'd prefere to put the variable name in single quotes here
as the name actually is '' (empty string)

<?php
$foo = "";
$$foo = "hallo";
echo ${""};
?>


-- 
Hartmut Holzgraefe  <hartmut@php.net

---

## #7806 — Derick Rethans — 2004-02-13T14:47:08+00:00

URL: https://externals.io/message/7804#7806 · In reply to: #7804

> Hey,
>
>         <?php
>         error_reporting(E_ALL);
>
>         echo $$foo;
>         ?>
>
> results in
>
>         Notice: Undefined variable: foo in /foo/bar.php on line 4
>
>         Notice: Undefined variable: in /foo/bar.php on line 4
>
> Wouldn't it be more appropriate if the second notice was something like
> "Notice: Undefined variable: <unnamed> in /foo/bar.php on line 4"?

Would be a lie... $foo WILL evaluate to the empty string which used like
this, although it does look weird, it is right :)

Derick
