3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php // taken from walf, http://www.php.net/manual/en/function.hex2bin.php // this function comes with PHP >= 5.4.0 if (!function_exists('hex2bin')) { function hex2bin($data) { static $old; if ($old === null) { $old = version_compare(PHP_VERSION, '5.2', '<'); } $isobj = false; if (is_scalar($data) || (($isobj = is_object($data)) && method_exists($data, '__toString'))) { if ($isobj && $old) { ob_start(); echo $data; $data = ob_get_clean(); } else { $data = (string) $data; } } else { trigger_error(__FUNCTION__.'() expects parameter 1 to be string, ' . gettype($data) . ' given', E_USER_WARNING); return; //null in this case } $len = strlen($data); if ($len % 2) { trigger_error(__FUNCTION__.'(): Hexadecimal input string must have an even length', E_USER_WARNING); return false; } if (strspn($data, '0123456789abcdefABCDEF') != $len) { trigger_error(__FUNCTION__.'(): Input string must be hexadecimal string', E_USER_WARNING); return false; } return pack('H*', $data); } } function heutf8($str, $ent_constant = ENT_COMPAT) { return htmlentities($str, $ent_constant, 'UTF-8'); } $str = hex2bin('c0206c61206d6169736f6e'); print(heutf8($str)); ?>
Finding entry points
Branch analysis from position: 0
Jump found. (Code = 43) Position 1 = 5, Position 2 = 6
Branch analysis from position: 5
Jump found. (Code = 62) Position 1 = -2
Branch analysis from position: 6
filename:       /in/BJEVR
function name:  (null)
number of ops:  16
compiled vars:  !0 = $str
line     #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   5     0  E >   INIT_FCALL                                               'function_exists'
         1        SEND_VAL                                                 'hex2bin'
         2        DO_ICALL                                         $1      
         3        BOOL_NOT                                         ~2      $1
         4      > JMPZ                                                     ~2, ->6
   6     5    >   DECLARE_FUNCTION                                         'hex2bin'
  39     6    >   NOP                                                      
  43     7        INIT_FCALL                                               'hex2bin'
         8        SEND_VAL                                                 'c0206c61206d6169736f6e'
         9        DO_ICALL                                         $3      
        10        ASSIGN                                                   !0, $3
  44    11        INIT_FCALL                                               'heutf8'
        12        SEND_VAR                                                 !0
        13        DO_FCALL                                      0  $5      
        14        ECHO                                                     $5
  46    15      > RETURN                                                   1

Function %00hex2bin%2Fin%2FBJEVR0x7f0574c0b46d:
Finding entry points
Branch analysis from position: 0
Jump found. (Code = 43) Position 1 = 4, Position 2 = 10
Branch analysis from position: 4
Jump found. (Code = 47) Position 1 = 15, Position 2 = 24
Branch analysis from position: 15
Jump found. (Code = 46) Position 1 = 18, Position 2 = 23
Branch analysis from position: 18
Jump found. (Code = 43) Position 1 = 25, Position 2 = 38
Branch analysis from position: 25
Jump found. (Code = 46) Position 1 = 26, Position 2 = 27
Branch analysis from position: 26
Jump found. (Code = 43) Position 1 = 28, Position 2 = 35
Branch analysis from position: 28
Jump found. (Code = 42) Position 1 = 37
Branch analysis from position: 37
Jump found. (Code = 42) Position 1 = 48
Branch analysis from position: 48
Jump found. (Code = 43) Position 1 = 52, Position 2 = 57
Branch analysis from position: 52
Jump found. (Code = 62) Position 1 = -2
Branch analysis from position: 57
Jump found. (Code = 43) Position 1 = 63, Position 2 = 68
Branch analysis from position: 63
Jump found. (Code = 62) Position 1 = -2
Branch analysis from position: 68
Jump found. (Code = 62) Position 1 = -2
Branch analysis from position: 35
Jump found. (Code = 42) Position 1 = 48
Branch analysis from position: 48
Branch analysis from position: 27
Branch analysis from position: 38
Jump found. (Code = 62) Position 1 = -2
Branch analysis from position: 23
Branch analysis from position: 24
Branch analysis from position: 10
filename:       /in/BJEVR
function name:  hex2bin
number of ops:  74
compiled vars:  !0 = $data, !1 = $old, !2 = $isobj, !3 = $len
line     #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   6     0  E >   RECV                                             !0      
   7     1        BIND_STATIC                                              !1, 'old'
   8     2        IS_IDENTICAL                                     ~4      !1, null
         3      > JMPZ                                                     ~4, ->10
   9     4    >   INIT_FCALL                                               'version_compare'
         5        SEND_VAL                                                 '7.1.0'
         6        SEND_VAL                                                 '5.2'
         7        SEND_VAL                                                 '%3C'
         8        DO_ICALL                                         $5      
         9        ASSIGN                                                   !1, $5
  11    10    >   ASSIGN                                                   !2, <false>
  12    11        INIT_FCALL                                               'is_scalar'
        12        SEND_VAR                                                 !0
        13        DO_ICALL                                         $8      
        14      > JMPNZ_EX                                         ~9      $8, ->24
        15    >   TYPE_CHECK                                    8  ~10     !0
        16        ASSIGN                                           $11     !2, ~10
        17      > JMPZ_EX                                          ~12     $11, ->23
        18    >   INIT_FCALL                                               'method_exists'
        19        SEND_VAR                                                 !0
        20        SEND_VAL                                                 '__toString'
        21        DO_ICALL                                         $13     
        22        BOOL                                             ~12     $13
        23    >   BOOL                                             ~9      ~12
        24    > > JMPZ                                                     ~9, ->38
  13    25    > > JMPZ_EX                                          ~14     !2, ->27
        26    >   BOOL                                             ~14     !1
        27    > > JMPZ                                                     ~14, ->35
  14    28    >   INIT_FCALL                                               'ob_start'
        29        DO_ICALL                                                 
  15    30        ECHO                                                     !0
  16    31        INIT_FCALL                                               'ob_get_clean'
        32        DO_ICALL                                         $16     
        33        ASSIGN                                                   !0, $16
        34      > JMP                                                      ->37
  19    35    >   CAST                                          6  ~18     !0
        36        ASSIGN                                                   !0, ~18
        37    > > JMP                                                      ->48
  23    38    >   INIT_FCALL                                               'trigger_error'
        39        INIT_FCALL                                               'gettype'
        40        SEND_VAR                                                 !0
        41        DO_ICALL                                         $20     
        42        CONCAT                                           ~21     'hex2bin%28%29+expects+parameter+1+to+be+string%2C+', $20
        43        CONCAT                                           ~22     ~21, '+given'
        44        SEND_VAL                                                 ~22
        45        SEND_VAL                                                 512
        46        DO_ICALL                                                 
  24    47      > RETURN                                                   null
  26    48    >   STRLEN                                           ~24     !0
        49        ASSIGN                                                   !3, ~24
  27    50        MOD                                              ~26     !3, 2
        51      > JMPZ                                                     ~26, ->57
  28    52    >   INIT_FCALL                                               'trigger_error'
        53        SEND_VAL                                                 'hex2bin%28%29%3A+Hexadecimal+input+string+must+have+an+even+length'
        54        SEND_VAL                                                 512
        55        DO_ICALL                                                 
  29    56      > RETURN                                                   <false>
  31    57    >   INIT_FCALL                                               'strspn'
        58        SEND_VAR                                                 !0
        59        SEND_VAL                                                 '0123456789abcdefABCDEF'
        60        DO_ICALL                                         $28     
        61        IS_NOT_EQUAL                                     ~29     $28, !3
        62      > JMPZ                                                     ~29, ->68
  32    63    >   INIT_FCALL                                               'trigger_error'
        64        SEND_VAL                                                 'hex2bin%28%29%3A+Input+string+must+be+hexadecimal+string'
        65        SEND_VAL                                                 512
        66        DO_ICALL                                                 
  33    67      > RETURN                                                   <false>
  35    68    >   INIT_FCALL                                               'pack'
        69        SEND_VAL                                                 'H%2A'
        70        SEND_VAR                                                 !0
        71        DO_ICALL                                         $31     
        72      > RETURN                                                   $31
  36    73*     > RETURN                                                   null

End of function %00hex2bin%2Fin%2FBJEVR0x7f0574c0b46d

Function heutf8:
Finding entry points
Branch analysis from position: 0
Jump found. (Code = 62) Position 1 = -2
filename:       /in/BJEVR
function name:  heutf8
number of ops:  9
compiled vars:  !0 = $str, !1 = $ent_constant
line     #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  39     0  E >   RECV                                             !0      
         1        RECV_INIT                                        !1      <const:'ENT_COMPAT'>
  40     2        INIT_FCALL                                               'htmlentities'
         3        SEND_VAR                                                 !0
         4        SEND_VAR                                                 !1
         5        SEND_VAL                                                 'UTF-8'
         6        DO_ICALL                                         $2      
         7      > RETURN                                                   $2
  41     8*     > RETURN                                                   null

End of function heutf8

Generated using Vulcan Logic Dumper, using php 7.3.0