3v4l.org

run code in 300+ PHP versions simultaneously
<?php $test_cases = array( "abc.txt" => '.', "https://3v4l.org/?foo" => '?', "https://3v4l.org/#bar" => '#', $_SERVER['PATH'] => ':', "PHP 8.3.8" => ' ', "192.168.1.1" => '.', "foo\nbar" => "\n", "snake_case" => '_', ); foreach ($test_cases as $string => $char) { if (strtok($string,$char)==pathinfo($string, PATHINFO_FILENAME)) { echo "\n\nSUCCESS: {$string} => {$char}"; } else { $string = str_replace("\n","\\n",$string); $char = str_replace("\n","\\n",$char); echo "\n\nFAILED: {$string} => {$char}"; echo "\n- strtok(): " . strtok($string,$char); echo "\n- pathinfo(): " . pathinfo($string, PATHINFO_FILENAME); }; }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 12, Position 2 = 60
Branch analysis from position: 12
2 jumps found. (Code = 78) Position 1 = 13, Position 2 = 60
Branch analysis from position: 13
2 jumps found. (Code = 43) Position 1 = 24, Position 2 = 30
Branch analysis from position: 24
1 jumps found. (Code = 42) Position 1 = 59
Branch analysis from position: 59
1 jumps found. (Code = 42) Position 1 = 12
Branch analysis from position: 12
Branch analysis from position: 30
1 jumps found. (Code = 42) Position 1 = 12
Branch analysis from position: 12
Branch analysis from position: 60
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 60
filename:       /in/RDYFs
function name:  (null)
number of ops:  62
compiled vars:  !0 = $test_cases, !1 = $char, !2 = $string
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   INIT_ARRAY                                       ~3      '.', 'abc.txt'
    5     1        ADD_ARRAY_ELEMENT                                ~3      '%3F', 'https%3A%2F%2F3v4l.org%2F%3Ffoo'
    6     2        ADD_ARRAY_ELEMENT                                ~3      '%23', 'https%3A%2F%2F3v4l.org%2F%23bar'
    7     3        FETCH_R                      global              ~4      '_SERVER'
          4        FETCH_DIM_R                                      ~5      ~4, 'PATH'
          5        ADD_ARRAY_ELEMENT                                ~3      '%3A', ~5
    8     6        ADD_ARRAY_ELEMENT                                ~3      '+', 'PHP+8.3.8'
    9     7        ADD_ARRAY_ELEMENT                                ~3      '.', '192.168.1.1'
   10     8        ADD_ARRAY_ELEMENT                                ~3      '%0A', 'foo%0Abar'
   11     9        ADD_ARRAY_ELEMENT                                ~3      '_', 'snake_case'
    3    10        ASSIGN                                                   !0, ~3
   13    11      > FE_RESET_R                                       $7      !0, ->60
         12    > > FE_FETCH_R                                       ~8      $7, !1, ->60
         13    >   ASSIGN                                                   !2, ~8
   14    14        INIT_FCALL                                               'strtok'
         15        SEND_VAR                                                 !2
         16        SEND_VAR                                                 !1
         17        DO_ICALL                                         $10     
         18        INIT_FCALL                                               'pathinfo'
         19        SEND_VAR                                                 !2
         20        SEND_VAL                                                 8
         21        DO_ICALL                                         $11     
         22        IS_EQUAL                                                 $10, $11
         23      > JMPZ                                                     ~12, ->30
   15    24    >   ROPE_INIT                                     4  ~14     '%0A%0ASUCCESS%3A+'
         25        ROPE_ADD                                      1  ~14     ~14, !2
         26        ROPE_ADD                                      2  ~14     ~14, '+%3D%3E+'
         27        ROPE_END                                      3  ~13     ~14, !1
         28        ECHO                                                     ~13
   14    29      > JMP                                                      ->59
   17    30    >   INIT_FCALL                                               'str_replace'
         31        SEND_VAL                                                 '%0A'
         32        SEND_VAL                                                 '%5Cn'
         33        SEND_VAR                                                 !2
         34        DO_ICALL                                         $16     
         35        ASSIGN                                                   !2, $16
   18    36        INIT_FCALL                                               'str_replace'
         37        SEND_VAL                                                 '%0A'
         38        SEND_VAL                                                 '%5Cn'
         39        SEND_VAR                                                 !1
         40        DO_ICALL                                         $18     
         41        ASSIGN                                                   !1, $18
   19    42        ROPE_INIT                                     4  ~21     '%0A%0AFAILED%3A+'
         43        ROPE_ADD                                      1  ~21     ~21, !2
         44        ROPE_ADD                                      2  ~21     ~21, '+%3D%3E+'
         45        ROPE_END                                      3  ~20     ~21, !1
         46        ECHO                                                     ~20
   20    47        INIT_FCALL                                               'strtok'
         48        SEND_VAR                                                 !2
         49        SEND_VAR                                                 !1
         50        DO_ICALL                                         $23     
         51        CONCAT                                           ~24     '%0A-+strtok%28%29%3A+++', $23
         52        ECHO                                                     ~24
   21    53        INIT_FCALL                                               'pathinfo'
         54        SEND_VAR                                                 !2
         55        SEND_VAL                                                 8
         56        DO_ICALL                                         $25     
         57        CONCAT                                           ~26     '%0A-+pathinfo%28%29%3A+', $25
         58        ECHO                                                     ~26
   13    59    > > JMP                                                      ->12
         60    >   FE_FREE                                                  $7
   23    61      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
140.87 ms | 1452 KiB | 16 Q