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) { $pattern = '~^(.*)(' . preg_quote($char) . '.*)$~U'; var_dump(strtok($string,$char) == preg_replace($pattern, '$1', $string)); }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 12, Position 2 = 34
Branch analysis from position: 12
2 jumps found. (Code = 78) Position 1 = 13, Position 2 = 34
Branch analysis from position: 13
1 jumps found. (Code = 42) Position 1 = 12
Branch analysis from position: 12
Branch analysis from position: 34
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 34
filename:       /in/SGWL5
function name:  (null)
number of ops:  36
compiled vars:  !0 = $test_cases, !1 = $char, !2 = $string, !3 = $pattern
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   INIT_ARRAY                                       ~4      '.', 'abc.txt'
    5     1        ADD_ARRAY_ELEMENT                                ~4      '%3F', 'https%3A%2F%2F3v4l.org%2F%3Ffoo'
    6     2        ADD_ARRAY_ELEMENT                                ~4      '%23', 'https%3A%2F%2F3v4l.org%2F%23bar'
    7     3        FETCH_R                      global              ~5      '_SERVER'
          4        FETCH_DIM_R                                      ~6      ~5, 'PATH'
          5        ADD_ARRAY_ELEMENT                                ~4      '%3A', ~6
    8     6        ADD_ARRAY_ELEMENT                                ~4      '+', 'PHP+8.3.8'
    9     7        ADD_ARRAY_ELEMENT                                ~4      '.', '192.168.1.1'
   10     8        ADD_ARRAY_ELEMENT                                ~4      '%0A', 'foo%0Abar'
   11     9        ADD_ARRAY_ELEMENT                                ~4      '_', 'snake_case'
    3    10        ASSIGN                                                   !0, ~4
   14    11      > FE_RESET_R                                       $8      !0, ->34
         12    > > FE_FETCH_R                                       ~9      $8, !1, ->34
         13    >   ASSIGN                                                   !2, ~9
   15    14        INIT_FCALL                                               'preg_quote'
         15        SEND_VAR                                                 !1
         16        DO_ICALL                                         $11     
         17        CONCAT                                           ~12     '%7E%5E%28.%2A%29%28', $11
         18        CONCAT                                           ~13     ~12, '.%2A%29%24%7EU'
         19        ASSIGN                                                   !3, ~13
   16    20        INIT_FCALL                                               'var_dump'
         21        INIT_FCALL                                               'strtok'
         22        SEND_VAR                                                 !2
         23        SEND_VAR                                                 !1
         24        DO_ICALL                                         $15     
         25        INIT_FCALL                                               'preg_replace'
         26        SEND_VAR                                                 !3
         27        SEND_VAL                                                 '%241'
         28        SEND_VAR                                                 !2
         29        DO_ICALL                                         $16     
         30        IS_EQUAL                                         ~17     $15, $16
         31        SEND_VAL                                                 ~17
         32        DO_ICALL                                                 
   14    33      > JMP                                                      ->12
         34    >   FE_FREE                                                  $8
   17    35      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
144.41 ms | 1457 KiB | 17 Q