3v4l.org

run code in 300+ PHP versions simultaneously
<?php $url = ''; /** @var non-empty-string|null $s */ function take_non_empty_string_or_null(?string $s): void { echo (string) $s; } function take_any_string(string $s): void { echo $s; } function take_an_int_or_null(?int $s): void { echo (int) $s; } /** * @param array{ * scheme?: non-empty-string, * user?: non-empty-string, * pass?: non-empty-string, * host?: non-empty-string, * port?: int, * path: string * query?: non-empty-string, * fragment?: non-empty-string, * } $arr */ function take_url(array $arr): void { foreach($arr as $v) { if (null !== $v) { take_any_string((string) v); } } } take_url(parse_url($url)); // array{} take_non_empty_string_or_null(parse_url($url, PHP_URL_SCHEME)); // null|non-empty-string take_non_empty_string_or_null(parse_url($url, PHP_URL_USER)); // null|non-empty-string take_non_empty_string_or_null(parse_url($url, PHP_URL_PASS)); // null|non-empty-string take_non_empty_string_or_null(parse_url($url, PHP_URL_HOST)); // null|non-empty-string take_an_int_or_null(parse_url($url, PHP_URL_PORT)); // null|int take_any_string(parse_url($url, PHP_URL_PATH)); // string take_non_empty_string_or_null(parse_url($url, PHP_URL_QUERY)); // null|non-empty-string take_non_empty_string_or_null(parse_url($url, PHP_URL_FRAGMENT)); // null|non-empty-string
Output for git.master_jit, git.master, rfc.property-hooks
Fatal error: Uncaught Error: Undefined constant "v" in /in/iHYqM:33 Stack trace: #0 /in/iHYqM(38): take_url(Array) #1 {main} thrown in /in/iHYqM on line 33
Process exited with code 255.

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:
78.71 ms | 405 KiB | 5 Q