phantm icon indicating copy to clipboard operation
phantm copied to clipboard

$_GET is of type Array('field'=> Top)

Open sk- opened this issue 11 years ago • 2 comments

The following code will produce the error

Notice: Type mismatch: expected: Array["id" => Any, ...], found: Array["id" => Top] echo $_GET['id'];

<?php

echo $_GET['id'];

sk- avatar Sep 11 '13 21:09 sk-

Hi,

indeed, because that's what it is. $_GET['id'] could be undefined, or assign to strings or arbitrary arrays. There is an option to make it less strict though.

colder avatar Sep 11 '13 21:09 colder

Sure, but what is troubling is that the message is hard to understand. What does Top mean? Does it mean undefined or string or array? For user defined arrays the type is much clearer.

Also, related to this, the following code does not produce any errors:


<?php

if (!is_array($_GET['id'])) {
    echo $_GET['id'];
}

and should warn about $_GET[id] being undefined.

sk- avatar Sep 11 '13 22:09 sk-