3v4l.org

run code in 500+ PHP versions simultaneously
<?php namespace App\Util; class Regex { /** @return list<string> */ public static function match(string $pattern, string $subject): array { $matches = []; \Safe\preg_match($pattern, $subject, $matches); assert(is_array($matches)); return $matches; } public static function replace(string $pattern, string $replacement, string $subject, int $limit = -1): string { $result = \Safe\preg_replace($pattern, $replacement, $subject, $limit); assert(is_string($result)); // cannot be otherwise when the parameters are strings return $result; } }
Output for 8.2.31 - 8.2.32, 8.3.0 - 8.3.33, 8.4.1 - 8.4.24, 8.5.0 - 8.5.9
Output for 4.3.0
Parse error: parse error, unexpected T_STRING in /in/oARtY on line 3
Process exited with code 255.

preferences:
46.24 ms | 754 KiB | 4 Q