3v4l.org

run code in 300+ PHP versions simultaneously
<?php function urlWhitelisted($url) { $always_allowed = array('localhost'); $whitelisted_domains = array('fxnetworks.com') + $always_allowed; $domain = parse_url($url); var_dump($domain); if (strpos($url, "/") === 0 || in_array($domain, $whitelisted_domains)) { return true; } foreach ($whitelisted_domains as $whitelisted_domain) { $whitelisted_domain = '.' . $whitelisted_domain; if (strpos($domain, $whitelisted_domain) === (strlen($domain) - strlen($whitelisted_domain))) { return true; } } return false; } $domains = array('/user', 'localhost/user', 'http://localhost:4039', 'http://fxnetworks.com/user', 'http://google.com', 'google.com', 'fxnetworks.com.google.com'); foreach($domains as $domain) { var_dump(urlWhitelisted($domain)); }
Output for git.master, git.master_jit, rfc.property-hooks
array(1) { ["path"]=> string(5) "/user" } bool(true) array(1) { ["path"]=> string(14) "localhost/user" } Fatal error: Uncaught TypeError: strpos(): Argument #1 ($haystack) must be of type string, array given in /in/H2pNe:17 Stack trace: #0 /in/H2pNe(17): strpos(Array, '.fxnetworks.com') #1 /in/H2pNe(28): urlWhitelisted('localhost/user') #2 {main} thrown in /in/H2pNe on line 17
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:
53.28 ms | 401 KiB | 8 Q