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((string)$test);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/nL7NX
function name:  (null)
number of ops:  11
compiled vars:  !0 = $name, !1 = $test
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   DECLARE_CLASS                                            'domainname'
   40     1        ASSIGN                                                   !0, 'apotheke-altenessen-s%5Cu00fcd.de'
   41     2        NEW                                              $3      'DomainName'
          3        SEND_VAR_EX                                              !0
          4        DO_FCALL                                      0          
          5        ASSIGN                                                   !1, $3
   44     6        INIT_FCALL                                               'print_r'
          7        CAST                                          6  ~6      !1
          8        SEND_VAL                                                 ~6
          9        DO_ICALL                                                 
         10      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FnL7NX%3A29%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/nL7NX
function name:  {closure}
number of ops:  13
compiled vars:  !0 = $match
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   29     0  E >   RECV                                             !0      
   30     1        INIT_FCALL                                               'mb_convert_encoding'
          2        INIT_FCALL                                               'pack'
          3        SEND_VAL                                                 'H%2A'
          4        FETCH_DIM_R                                      ~1      !0, 1
          5        SEND_VAL                                                 ~1
          6        DO_ICALL                                         $2      
          7        SEND_VAR                                                 $2
          8        SEND_VAL                                                 'UTF-8'
          9        SEND_VAL                                                 'UCS-2BE'
         10        DO_ICALL                                         $3      
         11      > RETURN                                                   $3
   31    12*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FnL7NX%3A29%240

Class DomainName:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/nL7NX
function name:  __construct
number of ops:  13
compiled vars:  !0 = $name, !1 = $decodeUnicodeName
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   RECV                                             !0      
   12     1        INIT_STATIC_METHOD_CALL                                  'decodeUnicode'
          2        SEND_VAR_EX                                              !0
          3        DO_FCALL                                      0  $2      
          4        ASSIGN                                                   !1, $2
   13     5        ASSIGN_OBJ                                               'name'
          6        OP_DATA                                                  !1
   14     7        INIT_STATIC_METHOD_CALL                                  'escapeDomainName'
          8        SEND_VAR_EX                                              !1
          9        DO_FCALL                                      0  $6      
         10        ASSIGN_OBJ                                               'escapedName'
         11        OP_DATA                                                  $6
   15    12      > RETURN                                                   null

End of function __construct

Function containssubdomain:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/nL7NX
function name:  containsSubdomain
number of ops:  8
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   19     0  E >   INIT_FCALL                                               'substr_count'
          1        FETCH_OBJ_R                                      ~0      'name'
          2        SEND_VAL                                                 ~0
          3        SEND_VAL                                                 '.'
          4        DO_ICALL                                         $1      
          5        IS_SMALLER_OR_EQUAL                              ~2      2, $1
          6      > RETURN                                                   ~2
   20     7*     > RETURN                                                   null

End of function containssubdomain

Function escapedomainname:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/nL7NX
function name:  escapeDomainName
number of ops:  8
compiled vars:  !0 = $name
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   22     0  E >   RECV                                             !0      
   24     1        INIT_FCALL                                               'preg_replace'
          2        SEND_VAL                                                 '%2F%5C.%2F'
          3        SEND_VAL                                                 '-'
          4        SEND_VAR                                                 !0
          5        DO_ICALL                                         $1      
          6      > RETURN                                                   $1
   25     7*     > RETURN                                                   null

End of function escapedomainname

Function decodeunicode:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/nL7NX
function name:  decodeUnicode
number of ops:  11
compiled vars:  !0 = $name
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   27     0  E >   RECV                                             !0      
   29     1        INIT_FCALL                                               'preg_replace_callback'
          2        SEND_VAL                                                 '%2F%5C%5Cu%28%5B0-9a-fA-F%5D%7B4%7D%29%2F'
          3        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FnL7NX%3A29%240'
   31     4        SEND_VAL                                                 ~1
          5        SEND_VAR                                                 !0
          6        DO_ICALL                                         $2      
          7        VERIFY_RETURN_TYPE                                       $2
          8      > RETURN                                                   $2
   32     9*       VERIFY_RETURN_TYPE                                       
         10*     > RETURN                                                   null

End of function decodeunicode

Function __tostring:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/nL7NX
function name:  __toString
number of ops:  6
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   36     0  E >   FETCH_OBJ_R                                      ~0      'name'
          1        CAST                                          6  ~1      ~0
          2        VERIFY_RETURN_TYPE                                       ~1
          3      > RETURN                                                   ~1
   37     4*       VERIFY_RETURN_TYPE                                       
          5*     > RETURN                                                   null

End of function __tostring

End of class DomainName.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
174.52 ms | 1404 KiB | 25 Q