3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?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); foreach( $matches as $match){ echo $match; }
Output for 5.0.0 - 5.6.28, 7.0.0 - 7.1.0
truetrue Warning: preg_match(): Unknown modifier '+' in /in/nsUaU on line 31
Output for hhvm-3.10.0 - 3.12.0
truetrue Warning: Unknown modifier '+': [(\d)+] in /in/nsUaU on line 31
Output for 4.4.5 - 4.4.9
Fatal error: Call to undefined function: substr_compare() in /in/nsUaU on line 8
Process exited with code 255.
Output for 4.3.2 - 4.4.4
Fatal error: Call to undefined function: substr_compare() in /in/nsUaU 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/nsUaU on line 8