3v4l.org

run code in 300+ PHP versions simultaneously
<?php $urls = [ 'https://example.com/api/', 'https://www.example.com/test-subpath', 'https://www.example.com', 'example.com/test/page', 'www.example.com', 'www.subdomain.example.com', 'https://www.subdomain.example.com', 'subdomain.example.com', 'http://subdomain.example.com', 'https://subdomain.example.com', ]; foreach ($urls as $url) { echo filter_var($url, FILTER_VALIDATE_URL) ? 'OKAY' : 'FAIL', ': ', $url, PHP_EOL; }
Output for 8.1.0 - 8.1.33, 8.2.0 - 8.2.29, 8.3.0 - 8.3.25, 8.4.1 - 8.4.12
OKAY: https://example.com/api/ OKAY: https://www.example.com/test-subpath OKAY: https://www.example.com FAIL: example.com/test/page FAIL: www.example.com FAIL: www.subdomain.example.com OKAY: https://www.subdomain.example.com FAIL: subdomain.example.com OKAY: http://subdomain.example.com OKAY: https://subdomain.example.com

preferences:
58.43 ms | 407 KiB | 5 Q