3v4l.org

run code in 300+ PHP versions simultaneously
<?php $basename = "a\xFFnything"; print("Before: ".$basename.PHP_EOL); $basename = preg_replace('/[\x00-\x1F]/u', '_', $basename); print("After: ".array_flip(get_defined_constants(true)['pcre'])[preg_last_error()]);
Output for 8.0.0 - 8.0.12, 8.1rc1 - rc3
Before: a�nything Warning: array_flip(): Can only flip string and integer values, entry skipped in /in/EfiFs on line 5 After: PREG_BAD_UTF8_ERROR
Output for 7.3.0 - 7.3.31, 7.4.0 - 7.4.25
Before: a�nything Warning: array_flip(): Can only flip STRING and INTEGER values! in /in/EfiFs on line 5 After: PREG_BAD_UTF8_ERROR
Output for 7.1.25 - 7.1.33, 7.2.0 - 7.2.33
Before: a�nything After: PREG_BAD_UTF8_ERROR

preferences:
43.89 ms | 462 KiB | 5 Q