3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php function reverseString($string) { $l = strlen($string); for($i=0; $i<$l/2; $i++) { $string[$i] = $string[$i] ^ $string[$l-$i]; $string[$l-$i] = $string[$i] ^ $string[$l-$i]; $string[$i] = $string[$i] ^ $string[$l-$i]; } return $string; } var_dump(reverseString('foo'));
Output for 7.1.0 - 7.1.7
Notice: Uninitialized string offset: 3 in /in/NJZOj on line 7 Warning: Cannot assign an empty string to a string offset in /in/NJZOj on line 7 Notice: Uninitialized string offset: 3 in /in/NJZOj on line 8 Warning: Cannot assign an empty string to a string offset in /in/NJZOj on line 8 Notice: Uninitialized string offset: 3 in /in/NJZOj on line 9 Warning: Cannot assign an empty string to a string offset in /in/NJZOj on line 9 string(3) "foo"
Output for 5.2.12 - 7.0.20
Notice: Uninitialized string offset: 3 in /in/NJZOj on line 7 Notice: Uninitialized string offset: 3 in /in/NJZOj on line 8 string(4) "oo"
Output for 5.2.10 - 5.2.11
Notice: Uninitialized string offset: 3 in /in/NJZOj on line 7 Notice: Uninitialized string offset: 3 in /in/NJZOj on line 8 Notice: Uninitialized string offset: 3 in /in/NJZOj on line 8 string(4) "oo"
Output for 4.3.0 - 5.2.9
Notice: Uninitialized string offset: 3 in /in/NJZOj on line 7 Notice: Uninitialized string offset: 3 in /in/NJZOj on line 8 string(4) "oo"