3v4l.org

run code in 500+ 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 = 31
Branch analysis from position: 12
2 jumps found. (Code = 78) Position 1 = 13, Position 2 = 31
Branch analysis from position: 13
1 jumps found. (Code = 42) Position 1 = 12
Branch analysis from position: 12
Branch analysis from position: 31
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 31
filename:       /in/SGWL5
function name:  (null)
number of ops:  33
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, ->31
         12    > > FE_FETCH_R                                           ~9      $8, !1, ->31
         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        FRAMELESS_ICALL_3                preg_replace        ~16     !3, '%241'
         26        OP_DATA                                                      !2
         27        IS_EQUAL                                             ~17     $15, ~16
         28        SEND_VAL                                                     ~17
         29        DO_ICALL                                                     
   14    30      > JMP                                                          ->12
         31    >   FE_FREE                                                      $8
   17    32      > RETURN                                                       1

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
159.76 ms | 1596 KiB | 16 Q