3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php function reverse($string) { $substr1 = ""; $substr2 = ""; $strLength = strlen($string); //$strLengthHalf = round($strLength / 2); for ($i = 0; $i < $strLengthHalf = round($strLength / 2); $i++) { var_dump($strLength-$i); var_dump($strLengthHalf - $i); $substr1 .= $string[$strLength-$i]; $substr2 .= $string[$strLengthHalf - $i]; } //var_dump($substr1); //var_dump($substr2); return $string = $substr1.$substr2; } var_dump(reverse('12345'));
based on QfMMA
Output for 5.4.5 - 5.6.28, 7.0.0 - 7.1.0
int(5) float(3) Notice: Uninitialized string offset: 5 in /in/Q0OZO on line 10 Notice: String offset cast occurred in /in/Q0OZO on line 11 int(4) float(2) Notice: String offset cast occurred in /in/Q0OZO on line 11 int(3) float(1) Notice: String offset cast occurred in /in/Q0OZO on line 11 string(5) "54432"
Output for hhvm-3.10.0 - 3.12.0
int(5) float(3) Notice: String offset cast occurred in /in/Q0OZO on line 11 int(4) float(2) Notice: String offset cast occurred in /in/Q0OZO on line 11 int(3) float(1) Notice: String offset cast occurred in /in/Q0OZO on line 11 string(5) "54432"
Output for 5.4.0 - 5.4.4
int(5) float(3) Notice: Uninitialized string offset: 5 in /in/Q0OZO on line 10 Notice: String offset cast occured in /in/Q0OZO on line 11 int(4) float(2) Notice: String offset cast occured in /in/Q0OZO on line 11 int(3) float(1) Notice: String offset cast occured in /in/Q0OZO on line 11 string(5) "54432"
Output for 5.2.10 - 5.3.29
int(5) float(3) Notice: Uninitialized string offset: 5 in /in/Q0OZO on line 10 int(4) float(2) int(3) float(1) string(5) "54432"
Output for 4.3.0 - 5.2.9
int(5) float(3) Notice: Uninitialized string offset: 5 in /in/Q0OZO on line 10 int(4) float(2) int(3) float(1) string(5) "54432"