3v4l.org

run code in 300+ PHP versions simultaneously
<?php const DNS_LABEL = '(?:[a-z0-9]|[a-z0-9][a-z0-9\-]{0,61}[a-z0-9])'; const DNS_NAME = '(?:' . DNS_LABEL . '\.)*' . DNS_LABEL; $input = 'bar.foo.com:443'; // $_SERVER['HTTP_HOST'] if (!\preg_match('(^(' . DNS_NAME . ')(?::[0-9]+)?$)i', $input, $match)) { throw new Exception('Not a valid DNS-based HTTP Host header'); } $lastTwoLabels = implode('.', array_slice(explode('.', $match[1]), -2)); var_dump($lastTwoLabels);
Output for git.master, git.master_jit, rfc.property-hooks
string(7) "foo.com"

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:
62.87 ms | 1922 KiB | 4 Q