12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- --TEST--
- Converting undefined index/offset notice to exception
- --FILE--
- <?php
- set_error_handler(function($_, $msg) {
- throw new Exception($msg);
- });
- $test = [];
- try {
- $test[0] .= "xyz";
- } catch (Exception $e) {
- echo $e->getMessage(), "\n";
- }
- var_dump($test);
- try {
- $test["key"] .= "xyz";
- } catch (Exception $e) {
- echo $e->getMessage(), "\n";
- }
- var_dump($test);
- unset($test);
- try {
- $GLOBALS["test"] .= "xyz";
- } catch (Exception $e) {
- echo $e->getMessage(), "\n";
- }
- try {
- var_dump($test);
- } catch (Exception $e) {
- echo $e->getMessage(), "\n";
- }
- ?>
- --EXPECT--
- Undefined array key 0
- array(0) {
- }
- Undefined array key "key"
- array(0) {
- }
- Undefined global variable $test
- Undefined variable $test
|