3v4l.org

run code in 300+ PHP versions simultaneously
<?php function is_palindrome(string $str): bool { return $str === implode('', array_reverse(grapheme_str_split($str))); } $palindrome = 'satanoscillatemymetallicsonatas'; $polar_bear = "\u{1f43b}\u{200d}\u{2744}\u{fe0f}"; $palindrome = str_replace('y', $polar_bear, $palindrome); echo "$palindrome is" . (is_palindrome($palindrome) ? "" : " not") . " a palindrome";
Output for 8.4.1 - 8.4.14
satanoscillatem🐻‍❄️metallicsonatas is a palindrome
Output for 8.2.0 - 8.2.29, 8.3.0 - 8.3.27
Fatal error: Uncaught Error: Call to undefined function grapheme_str_split() in /in/PuVIl:4 Stack trace: #0 /in/PuVIl(10): is_palindrome('satanoscillatem...') #1 {main} thrown in /in/PuVIl on line 4
Process exited with code 255.

preferences:
46.37 ms | 407 KiB | 5 Q