3v4l.org

run code in 500+ 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:  15
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                                                   'array_map'
          3        DECLARE_LAMBDA_FUNCTION                              ~3      [0]
          4        BIND_LEXICAL                                                 ~3, !1
          5        SEND_VAL                                                     ~3
          6        INIT_FCALL                                                   'str_split'
          7        SEND_VAR                                                     !0
          8        SEND_VAL                                                     1
          9        DO_ICALL                                             $4      
         10        SEND_VAR                                                     $4
         11        DO_ICALL                                             $5      
         12        FRAMELESS_ICALL_2                implode             ~6      '', $5
         13      > RETURN                                                       ~6
    6    14*     > RETURN                                                       null


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/EaN9Z
function name:  {closure:make_literal():5}
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 Dynamic Function 0

End of function make_literal

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.5.0


preferences:
163.3 ms | 2038 KiB | 24 Q