3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php function reverse($string) { $substr1 = ""; $substr2 = ""; $strLength = strlen($string)-1; $strLengthHalf = round(strlen($string)-1 / 2); var_dump($strLength); var_dump($strLengthHalf); for ($i = 0; $i < $strLengthHalf - 1; $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 pFhmD
Output for 5.4.5 - 7.1.0
int(4) float(5) Notice: String offset cast occurred in /in/qRT0Q on line 11 Notice: Uninitialized string offset: 5 in /in/qRT0Q on line 11 Notice: String offset cast occurred in /in/qRT0Q on line 11 Notice: String offset cast occurred in /in/qRT0Q on line 11 Notice: String offset cast occurred in /in/qRT0Q on line 11 string(4) "5432" string(3) "543" string(7) "5432543"
Output for 5.4.0 - 5.4.4
int(4) float(5) Notice: String offset cast occured in /in/qRT0Q on line 11 Notice: Uninitialized string offset: 5 in /in/qRT0Q on line 11 Notice: String offset cast occured in /in/qRT0Q on line 11 Notice: String offset cast occured in /in/qRT0Q on line 11 Notice: String offset cast occured in /in/qRT0Q on line 11 string(4) "5432" string(3) "543" string(7) "5432543"
Output for 5.2.10 - 5.3.29
int(4) float(5) Notice: Uninitialized string offset: 5 in /in/qRT0Q on line 11 string(4) "5432" string(3) "543" string(7) "5432543"
Output for 4.3.0 - 5.2.9
int(4) float(5) Notice: Uninitialized string offset: 5 in /in/qRT0Q on line 11 string(4) "5432" string(3) "543" string(7) "5432543"