Hi,

My name is Raphaël. I'm testing an idea before sending (with your help) a
RFC. Thank for your feedback!

This is a well-known PHP message:

Notice: Undefined index: id in /xxx/yyy on line 5


Now this is a code example I have seen several times:

$foos = get_foos();
$bar = get_bar();

foreach($foos as $foo) {
    if ($foo['id'] == $bar['id']) {
        echo 'found!';
    }
}


I think there is a problem with the error message in this type of case: is
$foo['id'] or $bar['id'] not set ? I don't know.

I'm not sure my example is relevant enough, but I think error message must
be as clear as possible to help user in debugging. And I just had a similar
problem today (and was thinking: "it's not the first time I see this kind
of problem").

So what I could propose may be replacing the error message by something
like:

Notice: Undefined index: id for $foo in /xxx/yyy on line 5


I'm not aware of the error code format, so I'm sure it must be adapted to
be more PHP-error-ish.

What do you think? *(side question: am I asking to the right place?)*

Regards,

Raphaël HUCHET

Have a nice day!

Reply via email to