3v4l.org

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