3v4l.org

run code in 300+ PHP versions simultaneously
<?php class DomainName { private $name; private $escapedName; public function __construct($name) { $decodeUnicodeName = static::decodeUnicode($name); $this->name = $decodeUnicodeName; $this->escapedName = static::escapeDomainName($decodeUnicodeName); } public function containsSubdomain() { return substr_count($this->name, '.') >= 2; } public static function escapeDomainName($name) { return preg_replace('/\./', '-', $name); } public static function decodeUnicode(string $name): string { return preg_replace_callback('/\\\\u([0-9a-fA-F]{4})/', function ($match) { return mb_convert_encoding(pack('H*', $match[1]), 'UTF-8', 'UCS-2BE'); }, $name); } public function __toString(): string { return (string)$this->name; } } $name = 'apotheke-altenessen-s\u00fcd.de'; $test = new DomainName($name); print_r($test->name);
Output for git.master, git.master_jit, rfc.property-hooks
Fatal error: Uncaught Error: Cannot access private property DomainName::$name in /in/2YlaP:44 Stack trace: #0 {main} thrown in /in/2YlaP on line 44
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:
85.2 ms | 401 KiB | 8 Q