3v4l.org

run code in 300+ PHP versions simultaneously
<?php function str_contains_eval( $show = '' ) { if ( str_contains( $show, 'url' ) || str_contains( $show, 'directory' ) || str_contains( $show, 'home' ) ) {} } function preg_match_eval( $show = '' ) { if ( preg_match( '/url|directory|home/', $show ) ) {} } $its = 1e3; $t = hrtime(true); for ( $i=0;$i++<$its;) $z = str_contains_eval( 'blogname' ); echo (hrtime(true)-$t)/1e9,"s\n"; $t = hrtime(true); for ( $i=0;$i++<$its;) $z = preg_match_eval( 'blogname' ); echo (hrtime(true)-$t)/1e9,"s\n"; echo "\n=== Warmed up ===\n\n"; $its = 1e5; $t = hrtime(true); for ( $i=0;$i++<$its;) $z = str_contains_eval( 'blogname' ); echo 'str_contains chain: ', $a=(hrtime(true)-$t)/1e9,"s\n"; $t = hrtime(true); for ( $i=0;$i++<$its;) $z = preg_match_eval( 'blogname' ); echo 'preg_match : ', $b=(hrtime(true)-$t)/1e9,"s\n"; echo 'preg_match is ', number_format((($a-$b)/$a) * 100, 2 ), "% faster than str_contains chain\n";

preferences:
25.14 ms | 407 KiB | 5 Q