3v4l.org

run code in 300+ PHP versions simultaneously
<?php function it($m,$p){echo ($p?'✔︎':'✘')." It $m\n"; if(!$p){$GLOBALS['f']=1;}}function done(){if(@$GLOBALS['f'])die(1);} $base_uri = 'http://localhost/symfony-standard/app_dev.php'; $base_uri_with_trailing_slash = $base_uri . '/'; $generate_uri = function($path) use ($base_uri) { return $base_uri . $path; }; $correctly_generate_uri = function($path, $base_uri) { $fix_path_for_base_uri = function ($path) use ($base_uri) { if ($path === '/') { return ''; } if (strlen($base_uri) === strrpos($base_uri, '/')+1) { return substr($path, 1); } return $path; }; return $base_uri . $fix_path_for_base_uri($path); }; print "\nBroken\n\n"; it( 'generates the expected uri: http://localhost/symfony-standard/app_dev.php', $base_uri === $generate_uri('/', $base_uri) ); it( 'generates the expected uri: http://localhost/symfony-standard/app_dev.php/foo', $base_uri.'/foo' === $generate_uri('/foo', $base_uri) ); print "\nNot Broken\n\n"; it( 'correctly generates the expected uri: http://localhost/symfony-standard/app_dev.php', $base_uri === $correctly_generate_uri('/', $base_uri) ); it( 'generates the expected uri: http://localhost/symfony-standard/app_dev.php/foo', $base_uri.'/foo' === $correctly_generate_uri('/foo', $base_uri) ); it( 'correctly generates the expected uri: http://localhost/symfony-standard/app_dev.php/', $base_uri_with_trailing_slash === $correctly_generate_uri('/', $base_uri_with_trailing_slash) ); it( 'correctly generates the expected uri: http://localhost/symfony-standard/app_dev.php/foo', $base_uri.'/foo' === $correctly_generate_uri('/foo', $base_uri_with_trailing_slash) );
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/eOUNC
function name:  (null)
number of ops:  68
compiled vars:  !0 = $base_uri, !1 = $base_uri_with_trailing_slash, !2 = $generate_uri, !3 = $correctly_generate_uri
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   ASSIGN                                                   !0, 'http%3A%2F%2Flocalhost%2Fsymfony-standard%2Fapp_dev.php'
    6     1        CONCAT                                           ~5      !0, '%2F'
          2        ASSIGN                                                   !1, ~5
    8     3        DECLARE_LAMBDA_FUNCTION                          ~7      [0]
          4        BIND_LEXICAL                                             ~7, !0
          5        ASSIGN                                                   !2, ~7
   13     6        DECLARE_LAMBDA_FUNCTION                          ~9      [1]
          7        ASSIGN                                                   !3, ~9
   30     8        ECHO                                                     '%0ABroken%0A%0A'
   32     9        INIT_FCALL                                               'it'
   33    10        SEND_VAL                                                 'generates+the+expected+uri%3A+http%3A%2F%2Flocalhost%2Fsymfony-standard%2Fapp_dev.php'
   34    11        INIT_DYNAMIC_CALL                                        !2
         12        SEND_VAL_EX                                              '%2F'
         13        SEND_VAR_EX                                              !0
         14        DO_FCALL                                      0  $11     
         15        IS_IDENTICAL                                     ~12     !0, $11
         16        SEND_VAL                                                 ~12
   32    17        DO_FCALL                                      0          
   37    18        INIT_FCALL                                               'it'
   38    19        SEND_VAL                                                 'generates+the+expected+uri%3A+http%3A%2F%2Flocalhost%2Fsymfony-standard%2Fapp_dev.php%2Ffoo'
   39    20        CONCAT                                           ~14     !0, '%2Ffoo'
         21        INIT_DYNAMIC_CALL                                        !2
         22        SEND_VAL_EX                                              '%2Ffoo'
         23        SEND_VAR_EX                                              !0
         24        DO_FCALL                                      0  $15     
         25        IS_IDENTICAL                                     ~16     $15, ~14
         26        SEND_VAL                                                 ~16
   37    27        DO_FCALL                                      0          
   42    28        ECHO                                                     '%0ANot+Broken%0A%0A'
   44    29        INIT_FCALL                                               'it'
   45    30        SEND_VAL                                                 'correctly+generates+the+expected+uri%3A+http%3A%2F%2Flocalhost%2Fsymfony-standard%2Fapp_dev.php'
   46    31        INIT_DYNAMIC_CALL                                        !3
         32        SEND_VAL_EX                                              '%2F'
         33        SEND_VAR_EX                                              !0
         34        DO_FCALL                                      0  $18     
         35        IS_IDENTICAL                                     ~19     !0, $18
         36        SEND_VAL                                                 ~19
   44    37        DO_FCALL                                      0          
   49    38        INIT_FCALL                                               'it'
   50    39        SEND_VAL                                                 'generates+the+expected+uri%3A+http%3A%2F%2Flocalhost%2Fsymfony-standard%2Fapp_dev.php%2Ffoo'
   51    40        CONCAT                                           ~21     !0, '%2Ffoo'
         41        INIT_DYNAMIC_CALL                                        !3
         42        SEND_VAL_EX                                              '%2Ffoo'
         43        SEND_VAR_EX                                              !0
         44        DO_FCALL                                      0  $22     
         45        IS_IDENTICAL                                     ~23     $22, ~21
         46        SEND_VAL                                                 ~23
   49    47        DO_FCALL                                      0          
   54    48        INIT_FCALL                                               'it'
   55    49        SEND_VAL                                                 'correctly+generates+the+expected+uri%3A+http%3A%2F%2Flocalhost%2Fsymfony-standard%2Fapp_dev.php%2F'
   56    50        INIT_DYNAMIC_CALL                                        !3
         51        SEND_VAL_EX                                              '%2F'
         52        SEND_VAR_EX                                              !1
         53        DO_FCALL                                      0  $25     
         54        IS_IDENTICAL                                     ~26     !1, $25
         55        SEND_VAL                                                 ~26
   54    56        DO_FCALL                                      0          
   59    57        INIT_FCALL                                               'it'
   60    58        SEND_VAL                                                 'correctly+generates+the+expected+uri%3A+http%3A%2F%2Flocalhost%2Fsymfony-standard%2Fapp_dev.php%2Ffoo'
   61    59        CONCAT                                           ~28     !0, '%2Ffoo'
         60        INIT_DYNAMIC_CALL                                        !3
         61        SEND_VAL_EX                                              '%2Ffoo'
         62        SEND_VAR_EX                                              !1
         63        DO_FCALL                                      0  $29     
         64        IS_IDENTICAL                                     ~30     $29, ~28
         65        SEND_VAL                                                 ~30
   59    66        DO_FCALL                                      0          
   62    67      > RETURN                                                   1


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/eOUNC
function name:  {closure}
number of ops:  5
compiled vars:  !0 = $path, !1 = $base_uri
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   RECV                                             !0      
          1        BIND_STATIC                                              !1
   10     2        CONCAT                                           ~2      !1, !0
          3      > RETURN                                                   ~2
   11     4*     > RETURN                                                   null

End of Dynamic Function 0

Dynamic Function 1
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/eOUNC
function name:  {closure}
number of ops:  11
compiled vars:  !0 = $path, !1 = $base_uri, !2 = $fix_path_for_base_uri
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   15     2        DECLARE_LAMBDA_FUNCTION                          ~3      [0]
          3        BIND_LEXICAL                                             ~3, !1
          4        ASSIGN                                                   !2, ~3
   27     5        INIT_DYNAMIC_CALL                                        !2
          6        SEND_VAR_EX                                              !0
          7        DO_FCALL                                      0  $5      
          8        CONCAT                                           ~6      !1, $5
          9      > RETURN                                                   ~6
   28    10*     > RETURN                                                   null


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 4, Position 2 = 5
Branch analysis from position: 4
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 5
2 jumps found. (Code = 43) Position 1 = 13, Position 2 = 18
Branch analysis from position: 13
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 18
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/eOUNC
function name:  {closure}
number of ops:  20
compiled vars:  !0 = $path, !1 = $base_uri
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   RECV                                             !0      
          1        BIND_STATIC                                              !1
   16     2        IS_IDENTICAL                                             !0, '%2F'
          3      > JMPZ                                                     ~2, ->5
   17     4    > > RETURN                                                   ''
   20     5    >   STRLEN                                           ~3      !1
          6        INIT_FCALL                                               'strrpos'
          7        SEND_VAR                                                 !1
          8        SEND_VAL                                                 '%2F'
          9        DO_ICALL                                         $4      
         10        ADD                                              ~5      $4, 1
         11        IS_IDENTICAL                                             ~3, ~5
         12      > JMPZ                                                     ~6, ->18
   21    13    >   INIT_FCALL                                               'substr'
         14        SEND_VAR                                                 !0
         15        SEND_VAL                                                 1
         16        DO_ICALL                                         $7      
         17      > RETURN                                                   $7
   24    18    > > RETURN                                                   !0
   25    19*     > RETURN                                                   null

End of Dynamic Function 0

End of Dynamic Function 1

Function it:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 3, Position 2 = 5
Branch analysis from position: 3
1 jumps found. (Code = 42) Position 1 = 6
Branch analysis from position: 6
2 jumps found. (Code = 43) Position 1 = 13, Position 2 = 15
Branch analysis from position: 13
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 15
Branch analysis from position: 5
2 jumps found. (Code = 43) Position 1 = 13, Position 2 = 15
Branch analysis from position: 13
Branch analysis from position: 15
filename:       /in/eOUNC
function name:  it
number of ops:  16
compiled vars:  !0 = $m, !1 = $p
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2      > JMPZ                                                     !1, ->5
          3    >   QM_ASSIGN                                        ~2      '%E2%9C%94%EF%B8%8E'
          4      > JMP                                                      ->6
          5    >   QM_ASSIGN                                        ~2      '%E2%9C%98'
          6    >   ROPE_INIT                                     3  ~4      '+It+'
          7        ROPE_ADD                                      1  ~4      ~4, !0
          8        ROPE_END                                      2  ~3      ~4, '%0A'
          9        CONCAT                                           ~6      ~2, ~3
         10        ECHO                                                     ~6
         11        BOOL_NOT                                         ~7      !1
         12      > JMPZ                                                     ~7, ->15
         13    >   FETCH_W                      global              $8      'f'
         14        ASSIGN                                                   $8, 1
         15    > > RETURN                                                   null

End of function it

Function done:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 4, Position 2 = 5
Branch analysis from position: 4
1 jumps found. (Code = 79) Position 1 = -2
Branch analysis from position: 5
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/eOUNC
function name:  done
number of ops:  6
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
          0  E >   BEGIN_SILENCE                                    ~0      
          1        FETCH_R                      global              ~1      'f'
          2        END_SILENCE                                              ~0
          3      > JMPZ                                                     ~1, ->5
          4    > > EXIT                                                     1
          5    > > RETURN                                                   null

End of function done

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
292.7 ms | 1027 KiB | 21 Q