3v4l.org

run code in 300+ PHP versions simultaneously
<?php // This function will take $_SERVER['REQUEST_URI'] and build a breadcrumb based on the user's current path function breadcrumbs($separator = ' &raquo; ', $home = 'Home') { // This gets the REQUEST_URI (/path/to/file.php), splits the string (using '/') into an array, and then filters out any empty values $path = array_filter(explode('/', parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH))); // This will build our "base URL" ... Also accounts for HTTPS :) $base = ($_SERVER['HTTPS'] ? 'https' : 'http') . '://' . $_SERVER['HTTP_HOST'] . '/'; // Initialize a temporary array with our breadcrumbs. (starting with our home page, which I'm assuming will be the base URL) $breadcrumbs = array("<a href=\"$base\">$home</a>"); // Find out the index for the last value in our path array $last = end(array_keys($path)); // Build the rest of the breadcrumbs foreach ($path AS $x => $crumb) { // Our "title" is the text that will be displayed (strip out .php and turn '_' into a space) $title = ucwords(str_replace(array('.php', '_'), array('', ' '), $crumb)); // If we are not on the last index, then display an <a> tag if ($x != $last) $breadcrumbs[] = "<a href=\"$base$crumb\">$title</a>"; // Otherwise, just display the title (minus) else $breadcrumbs[] = $title; } // Build our temporary array (pieces of bread) into one big string :) return implode($separator, $breadcrumbs); } echo breadcrumbs();
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/lGej4
function name:  (null)
number of ops:  4
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   36     0  E >   INIT_FCALL                                               'breadcrumbs'
          1        DO_FCALL                                      0  $0      
          2        ECHO                                                     $0
          3      > RETURN                                                   1

Function breadcrumbs:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 19, Position 2 = 21
Branch analysis from position: 19
1 jumps found. (Code = 42) Position 1 = 22
Branch analysis from position: 22
2 jumps found. (Code = 77) Position 1 = 43, Position 2 = 68
Branch analysis from position: 43
2 jumps found. (Code = 78) Position 1 = 44, Position 2 = 68
Branch analysis from position: 44
2 jumps found. (Code = 43) Position 1 = 56, Position 2 = 65
Branch analysis from position: 56
1 jumps found. (Code = 42) Position 1 = 67
Branch analysis from position: 67
1 jumps found. (Code = 42) Position 1 = 43
Branch analysis from position: 43
Branch analysis from position: 65
1 jumps found. (Code = 42) Position 1 = 43
Branch analysis from position: 43
Branch analysis from position: 68
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 68
Branch analysis from position: 21
2 jumps found. (Code = 77) Position 1 = 43, Position 2 = 68
Branch analysis from position: 43
Branch analysis from position: 68
filename:       /in/lGej4
function name:  breadcrumbs
number of ops:  75
compiled vars:  !0 = $separator, !1 = $home, !2 = $path, !3 = $base, !4 = $breadcrumbs, !5 = $last, !6 = $crumb, !7 = $x, !8 = $title
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   RECV_INIT                                        !0      '+%26raquo%3B+'
          1        RECV_INIT                                        !1      'Home'
    6     2        INIT_FCALL                                               'array_filter'
          3        INIT_FCALL                                               'explode'
          4        SEND_VAL                                                 '%2F'
          5        INIT_FCALL                                               'parse_url'
          6        FETCH_R                      global              ~9      '_SERVER'
          7        FETCH_DIM_R                                      ~10     ~9, 'REQUEST_URI'
          8        SEND_VAL                                                 ~10
          9        SEND_VAL                                                 5
         10        DO_ICALL                                         $11     
         11        SEND_VAR                                                 $11
         12        DO_ICALL                                         $12     
         13        SEND_VAR                                                 $12
         14        DO_ICALL                                         $13     
         15        ASSIGN                                                   !2, $13
    9    16        FETCH_R                      global              ~15     '_SERVER'
         17        FETCH_DIM_R                                      ~16     ~15, 'HTTPS'
         18      > JMPZ                                                     ~16, ->21
         19    >   QM_ASSIGN                                        ~17     'https'
         20      > JMP                                                      ->22
         21    >   QM_ASSIGN                                        ~17     'http'
         22    >   CONCAT                                           ~18     ~17, '%3A%2F%2F'
         23        FETCH_R                      global              ~19     '_SERVER'
         24        FETCH_DIM_R                                      ~20     ~19, 'HTTP_HOST'
         25        CONCAT                                           ~21     ~18, ~20
         26        CONCAT                                           ~22     ~21, '%2F'
         27        ASSIGN                                                   !3, ~22
   12    28        ROPE_INIT                                     5  ~25     '%3Ca+href%3D%22'
         29        ROPE_ADD                                      1  ~25     ~25, !3
         30        ROPE_ADD                                      2  ~25     ~25, '%22%3E'
         31        ROPE_ADD                                      3  ~25     ~25, !1
         32        ROPE_END                                      4  ~24     ~25, '%3C%2Fa%3E'
         33        INIT_ARRAY                                       ~28     ~24
         34        ASSIGN                                                   !4, ~28
   15    35        INIT_FCALL                                               'end'
         36        INIT_FCALL                                               'array_keys'
         37        SEND_VAR                                                 !2
         38        DO_ICALL                                         $30     
         39        SEND_VAR_NO_REF                               0          $30
         40        DO_ICALL                                         $31     
         41        ASSIGN                                                   !5, $31
   18    42      > FE_RESET_R                                       $33     !2, ->68
         43    > > FE_FETCH_R                                       ~34     $33, !6, ->68
         44    >   ASSIGN                                                   !7, ~34
   20    45        INIT_FCALL                                               'ucwords'
         46        INIT_FCALL                                               'str_replace'
         47        SEND_VAL                                                 <array>
         48        SEND_VAL                                                 <array>
         49        SEND_VAR                                                 !6
         50        DO_ICALL                                         $36     
         51        SEND_VAR                                                 $36
         52        DO_ICALL                                         $37     
         53        ASSIGN                                                   !8, $37
   23    54        IS_NOT_EQUAL                                             !7, !5
         55      > JMPZ                                                     ~39, ->65
   24    56    >   ROPE_INIT                                     6  ~42     '%3Ca+href%3D%22'
         57        ROPE_ADD                                      1  ~42     ~42, !3
         58        ROPE_ADD                                      2  ~42     ~42, !6
         59        ROPE_ADD                                      3  ~42     ~42, '%22%3E'
         60        ROPE_ADD                                      4  ~42     ~42, !8
         61        ROPE_END                                      5  ~41     ~42, '%3C%2Fa%3E'
         62        ASSIGN_DIM                                               !4
         63        OP_DATA                                                  ~41
         64      > JMP                                                      ->67
   27    65    >   ASSIGN_DIM                                               !4
         66        OP_DATA                                                  !8
   18    67    > > JMP                                                      ->43
         68    >   FE_FREE                                                  $33
   31    69        INIT_FCALL                                               'implode'
         70        SEND_VAR                                                 !0
         71        SEND_VAR                                                 !4
         72        DO_ICALL                                         $46     
         73      > RETURN                                                   $46
   32    74*     > RETURN                                                   null

End of function breadcrumbs

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
191.79 ms | 1411 KiB | 30 Q