3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?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);
based on ETcIZ
Output for 7.0.28 - 7.3.0rc3
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.
Output for 5.6.38
Parse error: syntax error, unexpected ':', expecting ';' or '{' in /in/2YlaP on line 27
Process exited with code 255.