@ 2015-12-22T10:26:36Z <?php
function bar(string $str){
$str[0] = "b";
var_dump($str);
}
$str = "";
$str[0] = "b";
var_dump($str);
bar("");
$str = "a";
$str[0] = "b";
var_dump($str);
$str = "a";
$str[1] = "b";
var_dump($str);
Enable javascript to submit You have javascript disabled. You will not be able to edit any code.
Output for 7.1.0 - 7.1.33 , 7.2.0 - 7.2.33 , 7.3.0 - 7.3.33 , 7.4.0 - 7.4.33 , 8.0.0 - 8.0.30 , 8.1.0 - 8.1.28 , 8.2.0 - 8.2.18 , 8.3.0 - 8.3.6 string(1) "b"
string(1) "b"
string(1) "b"
string(2) "ab"
Output for 7.0.0 - 7.0.33 array(1) {
[0]=>
string(1) "b"
}
array(1) {
[0]=>
string(1) "b"
}
string(1) "b"
string(2) "ab"
Output for 5.5.0 - 5.5.38 , 5.6.0 - 5.6.40 array(1) {
[0]=>
string(1) "b"
}
Catchable fatal error: Argument 1 passed to bar() must be an instance of string, string given, called in /in/5nKmu on line 12 and defined in /in/5nKmu on line 3
Process exited with code 255 . preferences:dark mode live preview
190.84 ms | 402 KiB | 326 Q