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, PHP_URL_HOST); 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'); foreach($domains as $domain) { var_dump(urlWhitelisted($domain)); }
Output for git.master, git.master_jit, rfc.property-hooks
bool(true) Deprecated: strpos(): Passing null to parameter #1 ($haystack) of type string is deprecated in /in/CiSY0 on line 16 Deprecated: strlen(): Passing null to parameter #1 ($string) of type string is deprecated in /in/CiSY0 on line 16 bool(false) bool(false) bool(true) bool(false)

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:
44.16 ms | 401 KiB | 8 Q