3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php /** * @param string $haystack * @param string $needle * * @return bool */ function str_starts_with( $haystack, $needle ) { $length = strlen( $needle ); var_dump(substr( $haystack, 0, $length ), $needle); var_dump(substr( $haystack, 0, $length ) == $needle); var_dump(substr( $haystack, 0, $length ) === $needle); var_dump(hash_equals(substr( $haystack, 0, $length ), $needle)); } str_starts_with( '', '' );
based on 5je2I
Output for hhvm-3.15.4, 7.0.0 - 7.3.0alpha1
string(0) "" string(0) "" bool(true) bool(true) bool(true)
Output for 5.6.0 - 5.6.30
bool(false) string(0) "" bool(true) bool(false) Warning: hash_equals(): Expected known_string to be a string, boolean given in /in/4XvPG on line 15 bool(false)