3v4l.org

run code in 300+ PHP versions simultaneously
<?php function getUserIP() { $ipas = null; $keys = array('HTTP_CLIENT_IP', 'HTTP_X_FORWARDED_FOR', 'HTTP_X_FORWARDED', 'HTTP_X_CLUSTER_CLIENT_IP', 'HTTP_FORWARDED_FOR', 'HTTP_FORWARDED', 'REMOTE_ADDR'); foreach($keys as $key) { $value = isset($_SERVER[$key]) ? $_SERVER[$key] : null; if(isset($value)) { foreach(explode(',', $value) as $ip) { if(false !== filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE)) { $ipas = $ip; } } } } return $ipas; } echo getUserIp();
Output for git.master, git.master_jit, rfc.property-hooks

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