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'; print_r(DomainName::decodeUnicode($name));
based on KMGHV
Output for 7.0.28 - 7.3.0rc4
apotheke-altenessen-süd.de
Output for 5.6.38
Parse error: syntax error, unexpected ':', expecting ';' or '{' in /in/pqa02 on line 27
Process exited with code 255.