3v4l.org

run code in 300+ PHP versions simultaneously
<?php function endswith($string, $test) { $strlen = strlen($string); $testlen = strlen($test); if ($testlen > $strlen) return false; return substr_compare($string, $test, -$testlen) === 0; } if(false == endswith('http://localhost/events/10','/events/')){ echo "true\n"; } else{ echo "false\n"; } $testlen = strlen('/bob/'); if(false == (substr_compare('http://localhost/events/10','/events/',-$testlen)===0)){ echo "true\n"; } else{ echo "false\n"; } $url = 'http://192.168.1.0/events/10'; //$eventid = intval(strpos($url,'/events/').); preg_match('^(\d)+^',$url,$matches,PREG_OFFSET_CAPTURE); $arraylen = count($matches); for($x=0;$x<$arraylen;$x++){ echo $matches[$0][$x][0]."\n"; }
Output for 5.4.0 - 5.4.16
Parse error: syntax error, unexpected '0' (T_LNUMBER), expecting variable (T_VARIABLE) or '$' in /in/MHom1 on line 34
Process exited with code 255.
Output for 5.3.0 - 5.3.26
Parse error: syntax error, unexpected T_LNUMBER, expecting T_VARIABLE or '$' in /in/MHom1 on line 34
Process exited with code 255.

preferences:
196.95 ms | 1395 KiB | 51 Q