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'; } else{ echo 'false'; } $testlen = strlen('/bob/'); if(false == (substr_compare('http://localhost/events/10','/events/',-$testlen)===0)){ echo 'true'; } else{ echo 'false'; } $url = 'http://localhost/events/10'; //$eventid = intval(strpos($url,'/events/').); $matches = array(); preg_match ('(\d)+',$url,$matches); echo $matches;
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.19, 8.3.0 - 8.3.7
truetrue Warning: preg_match(): Unknown modifier '+' in /in/fT89X on line 31 Warning: Array to string conversion in /in/fT89X on line 32 Array
Output for 5.4.0 - 5.4.45, 5.5.0 - 5.5.10, 5.5.12 - 5.5.38, 5.6.0 - 5.6.40, 7.0.0 - 7.0.33, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.31, 7.4.0 - 7.4.33
truetrue Warning: preg_match(): Unknown modifier '+' in /in/fT89X on line 31 Notice: Array to string conversion in /in/fT89X on line 32 Array
Output for 5.0.0 - 5.0.5, 5.1.0 - 5.1.6, 5.2.0 - 5.2.17, 5.3.0 - 5.3.29, 7.3.32 - 7.3.33
truetrue Warning: preg_match(): Unknown modifier '+' in /in/fT89X on line 31 Array
Output for 5.5.11
falsefalse Warning: preg_match(): Unknown modifier '+' in /in/fT89X on line 31 Notice: Array to string conversion in /in/fT89X on line 32 Array
Output for 4.4.5 - 4.4.9
Fatal error: Call to undefined function: substr_compare() in /in/fT89X on line 8
Process exited with code 255.
Output for 4.3.2 - 4.3.11, 4.4.0 - 4.4.4
Fatal error: Call to undefined function: substr_compare() in /in/fT89X on line 8
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Fatal error: Call to undefined function: substr_compare() in /in/fT89X on line 8

preferences:
339.85 ms | 401 KiB | 462 Q