3v4l.org

run code in 300+ PHP versions simultaneously
<?php /* * preg_match() and //u pattern modifier * * @link https://stackoverflow.com/a/6723593/367456 */ $constants = function_exists('get_defined_constants') ? @get_defined_constants(true) : null; $pcreConstants = (array)@$constants['pcre']; $pcreConstants = null; if (empty($pcreConstants)) { $pcreConstants = array(); foreach (get_defined_constants() as $constant => $value) { if (6 === sscanf($constant, '%*[P]%*1[CR]%*1[RE]%*1[EG]%*[_]%n', $n)) { $pcreConstants[$constant] = $value; } } } $kMap = array_flip(array_keys($pcreConstants)); $ofVer = @$kMap['PCRE_VERSION']; $stop = $ofVer ? $ofVer : count($pcreConstants); $ofFirst = intval(@$kMap['PREG_NO_ERROR']); $errors = array_flip(array_slice($pcreConstants, $ofFirst, - $ofFirst + $stop)); $return = preg_match('//u', "\x80"); $matchesUTF8 = 1 === $return; $isMatchError = false === $return; $pregLastError = function_exists('preg_last_error') ? preg_last_error() : null; $pregLastErrorMsg = function_exists('preg_last_error_msg') ? preg_last_error_msg() : null; printf("\$return: %s\n", var_export($return, true)); printf("\$matchesUTF8: %s\n", var_export($matchesUTF8, true)); printf("\$isMatchError: %s\n", var_export($isMatchError, true)); printf("\$pregLastError: %s\n", var_export($pregLastError, true)); printf("\$pregLastErrorMsg: %s\n", var_export($pregLastErrorMsg, true)); printf("PREG_*_ERROR: %s\n", var_export(@$errors[$pregLastError], true)); printf("PCRE_VERSION: %s\n", @$pcreConstants['PCRE_VERSION']); $extPcreVer = function_exists('phpversion') ? @phpversion('pcre') : null; if ($extPcreVer === PHP_VERSION) $extPcreVer = 'PHP_VERSION'; printf("ext-pcre version: %s\n", var_export($extPcreVer, true)); echo 'pcre constants: ', print_r($pcreConstants, true);
Output for git.master_jit, git.master
$return: false $matchesUTF8: false $isMatchError: true $pregLastError: 4 $pregLastErrorMsg: 'Malformed UTF-8 characters, possibly incorrectly encoded' PREG_*_ERROR: 'PREG_BAD_UTF8_ERROR' PCRE_VERSION: 10.44 2024-06-07 ext-pcre version: 'PHP_VERSION' pcre constants: Array ( [PREG_PATTERN_ORDER] => 1 [PREG_SET_ORDER] => 2 [PREG_OFFSET_CAPTURE] => 256 [PREG_UNMATCHED_AS_NULL] => 512 [PREG_SPLIT_NO_EMPTY] => 1 [PREG_SPLIT_DELIM_CAPTURE] => 2 [PREG_SPLIT_OFFSET_CAPTURE] => 4 [PREG_GREP_INVERT] => 1 [PREG_NO_ERROR] => 0 [PREG_INTERNAL_ERROR] => 1 [PREG_BACKTRACK_LIMIT_ERROR] => 2 [PREG_RECURSION_LIMIT_ERROR] => 3 [PREG_BAD_UTF8_ERROR] => 4 [PREG_BAD_UTF8_OFFSET_ERROR] => 5 [PREG_JIT_STACKLIMIT_ERROR] => 6 [PCRE_VERSION] => 10.44 2024-06-07 [PCRE_VERSION_MAJOR] => 10 [PCRE_VERSION_MINOR] => 44 [PCRE_JIT_SUPPORT] => 1 )
Output for rfc.property-hooks
$return: false $matchesUTF8: false $isMatchError: true $pregLastError: 4 $pregLastErrorMsg: 'Malformed UTF-8 characters, possibly incorrectly encoded' PREG_*_ERROR: 'PREG_BAD_UTF8_ERROR' PCRE_VERSION: 10.43 2024-02-16 ext-pcre version: 'PHP_VERSION' pcre constants: Array ( [PREG_PATTERN_ORDER] => 1 [PREG_SET_ORDER] => 2 [PREG_OFFSET_CAPTURE] => 256 [PREG_UNMATCHED_AS_NULL] => 512 [PREG_SPLIT_NO_EMPTY] => 1 [PREG_SPLIT_DELIM_CAPTURE] => 2 [PREG_SPLIT_OFFSET_CAPTURE] => 4 [PREG_GREP_INVERT] => 1 [PREG_NO_ERROR] => 0 [PREG_INTERNAL_ERROR] => 1 [PREG_BACKTRACK_LIMIT_ERROR] => 2 [PREG_RECURSION_LIMIT_ERROR] => 3 [PREG_BAD_UTF8_ERROR] => 4 [PREG_BAD_UTF8_OFFSET_ERROR] => 5 [PREG_JIT_STACKLIMIT_ERROR] => 6 [PCRE_VERSION] => 10.43 2024-02-16 [PCRE_VERSION_MAJOR] => 10 [PCRE_VERSION_MINOR] => 43 [PCRE_JIT_SUPPORT] => 1 )

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
29.21 ms | 410 KiB | 5 Q