# E_NOTICE/E_STRICT/E_WARNING thrown on bad arrays initialization?

- Thread: https://externals.io/message/18666
- Original archive: https://news-web.php.net/php.internals/18666
- Started by Etienne Kneuss on 2005-09-04T10:37:32+00:00
- Messages: 4
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · RFCs at https://externals.io/rfc.md · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #18666 — Etienne Kneuss — 2005-09-04T10:37:32+00:00

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

Hi,

As you surely know, arrays are often badly initialized:

<?php
// $array is undefined
$array['index'] = 'value';
 ?>

Wouldn't it be such a good thing to let the programmers know that this
is a bad habit, by throwing a +/- pedantic error ? I'm not sure which
type would suit for it, but I think its important enough to throw a
E_NOTICE.

It can be dangerous if the script is ran on an environment where
register_globals is enabled.
I wrote a paper about this kind of leak if you can't imagine an example:
http://www.colder.ch/news/09-04-2005/4/another-example-showing-t.html

Thanks for your interrest

-- 
Etienne Kneuss

http://www.colder.ch/
colder@php.net

---

## #18667 — Ron Korving — 2005-09-04T11:00:34+00:00

URL: https://externals.io/message/18666#18667 · In reply to: #18666

I agree. I've always found it weird that no notice is thrown in this
situation. Still I discourage people to code like this.

Ron


"Etienne Kneuss" <colder@php.net> wrote in message
news:431ACE6C.3060006@php.net...
> Hi,
>
> As you surely know, arrays are often badly initialized:
>
> <?php
> // $array is undefined
> $array['index'] = 'value';
>  ?>
>
> Wouldn't it be such a good thing to let the programmers know that this
> is a bad habit, by throwing a +/- pedantic error ? I'm not sure which
> type would suit for it, but I think its important enough to throw a
> E_NOTICE.
>
> It can be dangerous if the script is ran on an environment where
> register_globals is enabled.
> I wrote a paper about this kind of leak if you can't imagine an example:
> http://www.colder.ch/news/09-04-2005/4/another-example-showing-t.html
>
> Thanks for your interrest
>
> -- 
> Etienne Kneuss
>
> http://www.colder.ch/
> colder@php.net

---

## #18668 — Sara Golemon — 2005-09-04T15:27:43+00:00

URL: https://externals.io/message/18666#18668 · In reply to: #18667

> > […]
>I agree. I've always found it weird that no notice is thrown in this
> situation. Still I discourage people to code like this.
> 
This was brought up about a year ago and dismissed.

-Sara

---

## #19150 — Sebastian Nohn — 2005-09-24T16:26:30+00:00

URL: https://externals.io/message/18666#19150 · In reply to: #18668

Sara Golemon wrote:
> > […]
> This was brought up about a year ago and dismissed.

No reason to not bring it up again.

Sebastian
