3v4l.org

run code in 300+ PHP versions simultaneously
<?php function make_literal($s) { $chars = [0x09 => "\t","\n",".","\f","\r", 0x20 => " ","!","\"","#","\$","%","&","'","(",")","*","+",",","-",".","/","0","1","2","3","4","5","6","7","8","9",":",";","<","=",">","?","@","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","[","\\","]","^","_","`","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","{","|","}","~"]; return implode("", array_map(fn($c) => $chars[ord($c)], str_split($s, 1))); } function test($s) { echo "is_literal = ", (is_literal($s) ? "true" : "false"), " for: $s\n"; } $a = "test"; test($a); test(strtoupper($a)); test(make_literal(strtoupper($a))); test(make_literal(json_encode($_SERVER)));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/EaN9Z
function name:  (null)
number of ops:  30
compiled vars:  !0 = $a
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   ASSIGN                                                   !0, 'test'
   11     1        INIT_FCALL                                               'test'
          2        SEND_VAR                                                 !0
          3        DO_FCALL                                      0          
   12     4        INIT_FCALL                                               'test'
          5        INIT_FCALL                                               'strtoupper'
          6        SEND_VAR                                                 !0
          7        DO_ICALL                                         $3      
          8        SEND_VAR                                                 $3
          9        DO_FCALL                                      0          
   13    10        INIT_FCALL                                               'test'
         11        INIT_FCALL                                               'make_literal'
         12        INIT_FCALL                                               'strtoupper'
         13        SEND_VAR                                                 !0
         14        DO_ICALL                                         $5      
         15        SEND_VAR                                                 $5
         16        DO_FCALL                                      0  $6      
         17        SEND_VAR                                                 $6
         18        DO_FCALL                                      0          
   14    19        INIT_FCALL                                               'test'
         20        INIT_FCALL                                               'make_literal'
         21        INIT_FCALL                                               'json_encode'
         22        FETCH_R                      global              ~8      '_SERVER'
         23        SEND_VAL                                                 ~8
         24        DO_ICALL                                         $9      
         25        SEND_VAR                                                 $9
         26        DO_FCALL                                      0  $10     
         27        SEND_VAR                                                 $10
         28        DO_FCALL                                      0          
         29      > RETURN                                                   1

Function make_literal:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/EaN9Z
function name:  make_literal
number of ops:  18
compiled vars:  !0 = $s, !1 = $chars
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
    4     1        ASSIGN                                                   !1, <array>
    5     2        INIT_FCALL                                               'implode'
          3        SEND_VAL                                                 ''
          4        INIT_FCALL                                               'array_map'
          5        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FEaN9Z%3A5%240'
          6        BIND_LEXICAL                                             ~3, !1
          7        SEND_VAL                                                 ~3
          8        INIT_FCALL                                               'str_split'
          9        SEND_VAR                                                 !0
         10        SEND_VAL                                                 1
         11        DO_ICALL                                         $4      
         12        SEND_VAR                                                 $4
         13        DO_ICALL                                         $5      
         14        SEND_VAR                                                 $5
         15        DO_ICALL                                         $6      
         16      > RETURN                                                   $6
    6    17*     > RETURN                                                   null

End of function make_literal

Function %00%7Bclosure%7D%2Fin%2FEaN9Z%3A5%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/EaN9Z
function name:  {closure}
number of ops:  8
compiled vars:  !0 = $c, !1 = $chars
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   RECV                                             !0      
          1        BIND_STATIC                                              !1
          2        INIT_FCALL                                               'ord'
          3        SEND_VAR                                                 !0
          4        DO_ICALL                                         $2      
          5        FETCH_DIM_R                                      ~3      !1, $2
          6      > RETURN                                                   ~3
          7*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FEaN9Z%3A5%240

Function test:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 6, Position 2 = 8
Branch analysis from position: 6
1 jumps found. (Code = 42) Position 1 = 9
Branch analysis from position: 9
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 8
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/EaN9Z
function name:  test
number of ops:  15
compiled vars:  !0 = $s
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   RECV                                             !0      
    8     1        ECHO                                                     'is_literal+%3D+'
          2        INIT_FCALL_BY_NAME                                       'is_literal'
          3        SEND_VAR_EX                                              !0
          4        DO_FCALL                                      0  $1      
          5      > JMPZ                                                     $1, ->8
          6    >   QM_ASSIGN                                        ~2      'true'
          7      > JMP                                                      ->9
          8    >   QM_ASSIGN                                        ~2      'false'
          9    >   ECHO                                                     ~2
         10        ROPE_INIT                                     3  ~4      '+for%3A+'
         11        ROPE_ADD                                      1  ~4      ~4, !0
         12        ROPE_END                                      2  ~3      ~4, '%0A'
         13        ECHO                                                     ~3
    9    14      > RETURN                                                   null

End of function test

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
179.38 ms | 1403 KiB | 31 Q