3v4l.org

run code in 300+ PHP versions simultaneously
<?php $values = [ 'ip' => '127.0.0.1', 'hostname' => 'localhost', 'ipport' => '127.0.0.1:3307', 'hostname' => 'localhost:3308', 'ipv6' => '[2001:0DB8::1234]', 'ipv6port' => '[2001:0DB8::1234]:3309', ]; foreach($values as $k=>$hostport) { $host = $hostport; $port = 'not found'; // has port or ipv6 if (strpos($hostport, ':')) { // ipv6 if (str_starts_with($hostport, '[')) { $portposition = strpos($hostport,']:'); if ($portposition) { $port = substr($hostport, $portposition+2); $host = substr($hostport, 0, $portposition+1); } } else { [$host, $port] = explode(':', $hostport); } } echo $k .': Hostname: ' . $host . ' Port: ' . $port ."\n"; }
Output for git.master_jit, git.master, rfc.property-hooks
ip: Hostname: 127.0.0.1 Port: not found hostname: Hostname: localhost Port: 3308 ipport: Hostname: 127.0.0.1 Port: 3307 ipv6: Hostname: [2001:0DB8::1234] Port: not found ipv6port: Hostname: [2001:0DB8::1234] Port: 3309

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