mirror of
https://github.com/php/php-src.git
synced 2024-12-02 22:34:55 +08:00
14bdb0cfc7
* Change a number of "resource used as offset" notices to warnings, which were previously missed. * Throw the "resource used as offset" warning for isset() as well. * Make array_key_exists() behavior with regard to different key types consistent with isset() and normal array accesses. All key types now use the usual coercions and array/object keys throw TypeError. Closes GH-4887.
49 lines
797 B
PHP
49 lines
797 B
PHP
--TEST--
|
|
Using isset() with arrays
|
|
--FILE--
|
|
<?php
|
|
|
|
$array = [
|
|
0 => true,
|
|
"a" => true,
|
|
];
|
|
|
|
var_dump(isset($array[0]));
|
|
|
|
var_dump(isset($array["a"]));
|
|
|
|
var_dump(isset($array[false]));
|
|
|
|
var_dump(isset($array[0.6]));
|
|
|
|
var_dump(isset($array[true]));
|
|
|
|
var_dump(isset($array[null]));
|
|
|
|
var_dump(isset($array[STDIN]));
|
|
|
|
try {
|
|
isset($array[[]]);
|
|
} catch (TypeError $exception) {
|
|
echo $exception->getMessage() . "\n";
|
|
}
|
|
|
|
try {
|
|
isset($array[new stdClass()]);
|
|
} catch (TypeError $exception) {
|
|
echo $exception->getMessage() . "\n";
|
|
}
|
|
?>
|
|
--EXPECTF--
|
|
bool(true)
|
|
bool(true)
|
|
bool(true)
|
|
bool(true)
|
|
bool(false)
|
|
bool(false)
|
|
|
|
Warning: Resource ID#%d used as offset, casting to integer (%d) in %s on line %d
|
|
bool(false)
|
|
Illegal offset type in isset or empty
|
|
Illegal offset type in isset or empty
|