<?php echo "\n#1: hello\n"; $a = 'hello'; var_dump($a['test']); // notice, but fetches the first char 'h' (undefined/null = 0) var_dump($a[false]); // notice, but fetches the first char 'h' (false = 0) var_dump($a[true]); // notice, but fetches the second char 'e' (true = 1) var_dump($a['2']); // notice, but fetches the second char 'e' (true = 1) echo "\n#2: 42\n"; $a = 42; var_dump($a['test']); // NO NOTICE, returns null var_dump($a[1]); // NO NOTICE, returns null var_dump($a[2]); // NO NOTICE, returns null echo "\n#2: null\n"; $a = null; var_dump($a['test']); // NO NOTICE, returns null var_dump($a[1]); // NO NOTICE, returns null var_dump($a[2]); // NO NOTICE, returns null echo "\nHave fun with it...\nbest regards,\nyour PHP";
You have javascript disabled. You will not be able to edit any code.