3v4l.org

run code in 300+ PHP versions simultaneously
<?php function get_list_view_html($product) { $output = ""; $output = $output . "<li>"; $output = $output . '<a href="' . BASE_URL . 'shirts/' . $product["sku"] . '/">'; $output = $output . '<img src="' . BASE_URL . $product["img"] . '" alt="' . $product["name"] . '">'; $output = $output . "<p>View Details</p>"; $output = $output . "</a>"; $output = $output . "</li>"; return $output; } function get_product_count() { } function get_products_recent() { $recent = array(); $all = get_products_all(); $total_products = count($all); $position = 0; foreach($all as $product) { $position = $position + 1; if ($total_products - $position < 4) { $recent[] = $product; } } return $recent; } function get_products_search($s) { $results = array(); $all = get_products_all(); foreach($all as $product) { if (stripos($product["name"],$s) !== false) { $results[] = $product; } } return $results; } function get_products_all() { $products = array(); $products[101] = array( "name" => "Logo Shirt, Red", "img" => "img/shirts/shirt-101.jpg", "price" => 18, "paypal" => "9P7DLECFD4LKE", "sizes" => array("Small","Medium","Large","X-Large") ); $products[102] = array( "name" => "Mike the Frog Shirt, Black", "img" => "img/shirts/shirt-102.jpg", "price" => 20, "paypal" => "SXKPTHN2EES3J", "sizes" => array("Small","Medium","Large","X-Large") ); $products[103] = array( "name" => "Mike the Frog Shirt, Blue", "img" => "img/shirts/shirt-103.jpg", "price" => 20, "paypal" => "7T8LK5WXT5Q9J", "sizes" => array("Small","Medium","Large","X-Large") ); $products[104] = array( "name" => "Logo Shirt, Green", "img" => "img/shirts/shirt-104.jpg", "price" => 18, "paypal" => "YKVL5F87E8PCS", "sizes" => array("Small","Medium","Large","X-Large") ); $products[105] = array( "name" => "Mike the Frog Shirt, Yellow", "img" => "img/shirts/shirt-105.jpg", "price" => 25, "paypal" => "4CLP2SCVYM288", "sizes" => array("Small","Medium","Large","X-Large") ); $products[106] = array( "name" => "Logo Shirt, Gray", "img" => "img/shirts/shirt-106.jpg", "price" => 20, "paypal" => "TNAZ2RGYYJ396", "sizes" => array("Small","Medium","Large","X-Large") ); $products[107] = array( "name" => "Logo Shirt, Teal", "img" => "img/shirts/shirt-107.jpg", "price" => 20, "paypal" => "S5FMPJN6Y2C32", "sizes" => array("Small","Medium","Large","X-Large") ); $products[108] = array( "name" => "Mike the Frog Shirt, Orange", "img" => "img/shirts/shirt-108.jpg", "price" => 25, "paypal" => "JMFK7P7VEHS44", "sizes" => array("Large","X-Large") ); $products[109] = array( "name" => "Get Coding Shirt, Gray", "img" => "img/shirts/shirt-109.jpg", "price" => 20, "paypal" => "B5DAJHWHDA4RC", "sizes" => array("Small","Medium","Large","X-Large") ); $products[110] = array( "name" => "HTML5 Shirt, Orange", "img" => "img/shirts/shirt-110.jpg", "price" => 22, "paypal" => "6T2LVA8EDZR8L", "sizes" => array("Small","Medium","Large","X-Large") ); $products[111] = array( "name" => "CSS3 Shirt, Gray", "img" => "img/shirts/shirt-111.jpg", "price" => 22, "paypal" => "MA2WQGE2KCWDS", "sizes" => array("Small","Medium","Large","X-Large") ); $products[112] = array( "name" => "HTML5 Shirt, Blue", "img" => "img/shirts/shirt-112.jpg", "price" => 22, "paypal" => "FWR955VF5PALA", "sizes" => array("Small","Medium","Large","X-Large") ); $products[113] = array( "name" => "CSS3 Shirt, Black", "img" => "img/shirts/shirt-113.jpg", "price" => 22, "paypal" => "4ELH2M2FW7272", "sizes" => array("Small","Medium","Large","X-Large") ); $products[114] = array( "name" => "PHP Shirt, Yellow", "img" => "img/shirts/shirt-114.jpg", "price" => 24, "paypal" => "AT3XQ3ZVP2DZG", "sizes" => array("Small","Medium","Large","X-Large") ); $products[115] = array( "name" => "PHP Shirt, Purple", "img" => "img/shirts/shirt-115.jpg", "price" => 24, "paypal" => "LYESEKV9JWE3A", "sizes" => array("Small","Medium","Large","X-Large") ); $products[116] = array( "name" => "PHP Shirt, Green", "img" => "img/shirts/shirt-116.jpg", "price" => 24, "paypal" => "KT7MRRJUXZR34", "sizes" => array("Small","Medium","Large","X-Large") ); $products[117] = array( "name" => "Get Coding Shirt, Red", "img" => "img/shirts/shirt-117.jpg", "price" => 20, "paypal" => "5UXJG8PXRXFKE", "sizes" => array("Small","Medium","Large","X-Large") ); $products[118] = array( "name" => "Mike the Frog Shirt, Purple", "img" => "img/shirts/shirt-118.jpg", "price" => 25, "paypal" => "KHP8PYPDZZFTA", "sizes" => array("Small","Medium","Large","X-Large") ); $products[119] = array( "name" => "CSS3 Shirt, Purple", "img" => "img/shirts/shirt-119.jpg", "price" => 22, "paypal" => "BFJRFE24L93NW", "sizes" => array("Small","Medium","Large","X-Large") ); $products[120] = array( "name" => "HTML5 Shirt, Red", "img" => "img/shirts/shirt-120.jpg", "price" => 22, "paypal" => "RUVJSBR9FXXWQ", "sizes" => array("Small","Medium","Large","X-Large") ); $products[122] = array( "name" => "PHP Shirt, Gray", "img" => "img/shirts/shirt-122.jpg", "price" => 24, "paypal" => "PYR4QH97W2TSJ", "sizes" => array("Small","Medium","Large","X-Large") ); $products[123] = array( "name" => "Mike the Frog Shirt, Green", "img" => "img/shirts/shirt-123.jpg", "price" => 25, "paypal" => "STDAUJJTSPT54", "sizes" => array("Small","Medium","Large","X-Large") ); $products[124] = array( "name" => "Logo Shirt, Yellow", "img" => "img/shirts/shirt-124.jpg", "price" => 20, "paypal" => "2R2U74KWU5RXG", "sizes" => array("Small","Medium","Large","X-Large") ); $products[125] = array( "name" => "CSS3 Shirt, Blue", "img" => "img/shirts/shirt-125.jpg", "price" => 22, "paypal" => "GJG7F8EW3XFAS", "sizes" => array("Small","Medium","Large","X-Large") ); $products[126] = array( "name" => "Doctype Shirt, Green", "img" => "img/shirts/shirt-126.jpg", "price" => 25, "paypal" => "QW2LFRYGU7L4Q", "sizes" => array("Small","Medium","Large","X-Large") ); $products[127] = array( "name" => "Logo Shirt, Purple", "img" => "img/shirts/shirt-127.jpg", "price" => 20, "paypal" => "GFV6QVRMJU7F8", "sizes" => array("Small","Medium","Large","X-Large") ); $products[128] = array( "name" => "Doctype Shirt, Purple", "img" => "img/shirts/shirt-128.jpg", "price" => 25, "paypal" => "BARQMHMB565PN", "sizes" => array("Small","Medium","Large","X-Large") ); $products[129] = array( "name" => "Get Coding Shirt, Green", "img" => "img/shirts/shirt-129.jpg", "price" => 20, "paypal" => "DH9GXABU3P8GS", "sizes" => array("Small","Medium","Large","X-Large") ); $products[130] = array( "name" => "HTML5 Shirt, Teal", "img" => "img/shirts/shirt-130.jpg", "price" => 22, "paypal" => "4LZ3EUVCBENE4", "sizes" => array("Small","Medium","Large","X-Large") ); $products[131] = array( "name" => "Logo Shirt, Orange", "img" => "img/shirts/shirt-131.jpg", "price" => 20, "paypal" => "7BNDYJBKWD364", "sizes" => array("Small","Medium","Large","X-Large") ); $products[132] = array( "name" => "Mike the Frog Shirt, Red", "img" => "img/shirts/shirt-132.jpg", "price" => 25, "paypal" => "Y6EQRE445MYYW", "sizes" => array("Small","Medium","Large","X-Large") ); foreach ($products as $product_id => $product) { $products[$product_id]["sku"] = $product_id; } return $products; } ?>
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/sJvMD
function name:  (null)
number of ops:  1
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  276     0  E > > RETURN                                                   1

Function get_list_view_html:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/sJvMD
function name:  get_list_view_html
number of ops:  30
compiled vars:  !0 = $product, !1 = $output
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
    5     1        ASSIGN                                                   !1, ''
    7     2        CONCAT                                           ~3      !1, '%3Cli%3E'
          3        ASSIGN                                                   !1, ~3
    8     4        CONCAT                                           ~5      !1, '%3Ca+href%3D%22'
          5        FETCH_CONSTANT                                   ~6      'BASE_URL'
          6        CONCAT                                           ~7      ~5, ~6
          7        CONCAT                                           ~8      ~7, 'shirts%2F'
          8        FETCH_DIM_R                                      ~9      !0, 'sku'
          9        CONCAT                                           ~10     ~8, ~9
         10        CONCAT                                           ~11     ~10, '%2F%22%3E'
         11        ASSIGN                                                   !1, ~11
    9    12        CONCAT                                           ~13     !1, '%3Cimg+src%3D%22'
         13        FETCH_CONSTANT                                   ~14     'BASE_URL'
         14        CONCAT                                           ~15     ~13, ~14
         15        FETCH_DIM_R                                      ~16     !0, 'img'
         16        CONCAT                                           ~17     ~15, ~16
         17        CONCAT                                           ~18     ~17, '%22+alt%3D%22'
         18        FETCH_DIM_R                                      ~19     !0, 'name'
         19        CONCAT                                           ~20     ~18, ~19
         20        CONCAT                                           ~21     ~20, '%22%3E'
         21        ASSIGN                                                   !1, ~21
   10    22        CONCAT                                           ~23     !1, '%3Cp%3EView+Details%3C%2Fp%3E'
         23        ASSIGN                                                   !1, ~23
   11    24        CONCAT                                           ~25     !1, '%3C%2Fa%3E'
         25        ASSIGN                                                   !1, ~25
   12    26        CONCAT                                           ~27     !1, '%3C%2Fli%3E'
         27        ASSIGN                                                   !1, ~27
   14    28      > RETURN                                                   !1
   15    29*     > RETURN                                                   null

End of function get_list_view_html

Function get_product_count:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/sJvMD
function name:  get_product_count
number of ops:  1
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   19     0  E > > RETURN                                                   null

End of function get_product_count

Function get_products_recent:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 8, Position 2 = 17
Branch analysis from position: 8
2 jumps found. (Code = 78) Position 1 = 9, Position 2 = 17
Branch analysis from position: 9
2 jumps found. (Code = 43) Position 1 = 14, Position 2 = 16
Branch analysis from position: 14
1 jumps found. (Code = 42) Position 1 = 8
Branch analysis from position: 8
Branch analysis from position: 16
Branch analysis from position: 17
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 17
filename:       /in/sJvMD
function name:  get_products_recent
number of ops:  20
compiled vars:  !0 = $recent, !1 = $all, !2 = $total_products, !3 = $position, !4 = $product
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   22     0  E >   ASSIGN                                                   !0, <array>
   23     1        INIT_FCALL_BY_NAME                                       'get_products_all'
          2        DO_FCALL                                      0  $6      
          3        ASSIGN                                                   !1, $6
   25     4        COUNT                                            ~8      !1
          5        ASSIGN                                                   !2, ~8
   26     6        ASSIGN                                                   !3, 0
   28     7      > FE_RESET_R                                       $11     !1, ->17
          8    > > FE_FETCH_R                                               $11, !4, ->17
   29     9    >   ADD                                              ~12     !3, 1
         10        ASSIGN                                                   !3, ~12
   30    11        SUB                                              ~14     !2, !3
         12        IS_SMALLER                                               ~14, 4
         13      > JMPZ                                                     ~15, ->16
   31    14    >   ASSIGN_DIM                                               !0
         15        OP_DATA                                                  !4
   28    16    > > JMP                                                      ->8
         17    >   FE_FREE                                                  $11
   34    18      > RETURN                                                   !0
   35    19*     > RETURN                                                   null

End of function get_products_recent

Function get_products_search:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 6, Position 2 = 17
Branch analysis from position: 6
2 jumps found. (Code = 78) Position 1 = 7, Position 2 = 17
Branch analysis from position: 7
2 jumps found. (Code = 43) Position 1 = 14, Position 2 = 16
Branch analysis from position: 14
1 jumps found. (Code = 42) Position 1 = 6
Branch analysis from position: 6
Branch analysis from position: 16
Branch analysis from position: 17
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 17
filename:       /in/sJvMD
function name:  get_products_search
number of ops:  20
compiled vars:  !0 = $s, !1 = $results, !2 = $all, !3 = $product
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   37     0  E >   RECV                                             !0      
   38     1        ASSIGN                                                   !1, <array>
   39     2        INIT_FCALL_BY_NAME                                       'get_products_all'
          3        DO_FCALL                                      0  $5      
          4        ASSIGN                                                   !2, $5
   41     5      > FE_RESET_R                                       $7      !2, ->17
          6    > > FE_FETCH_R                                               $7, !3, ->17
   42     7    >   INIT_FCALL                                               'stripos'
          8        FETCH_DIM_R                                      ~8      !3, 'name'
          9        SEND_VAL                                                 ~8
         10        SEND_VAR                                                 !0
         11        DO_ICALL                                         $9      
         12        TYPE_CHECK                                  1018          $9
         13      > JMPZ                                                     ~10, ->16
   43    14    >   ASSIGN_DIM                                               !1
         15        OP_DATA                                                  !3
   41    16    > > JMP                                                      ->6
         17    >   FE_FREE                                                  $7
   46    18      > RETURN                                                   !1
   47    19*     > RETURN                                                   null

End of function get_products_search

Function get_products_all:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 64, Position 2 = 70
Branch analysis from position: 64
2 jumps found. (Code = 78) Position 1 = 65, Position 2 = 70
Branch analysis from position: 65
1 jumps found. (Code = 42) Position 1 = 64
Branch analysis from position: 64
Branch analysis from position: 70
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 70
filename:       /in/sJvMD
function name:  get_products_all
number of ops:  73
compiled vars:  !0 = $products, !1 = $product, !2 = $product_id
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   50     0  E >   ASSIGN                                                   !0, <array>
   51     1        ASSIGN_DIM                                               !0, 101
   52     2        OP_DATA                                                  <array>
   58     3        ASSIGN_DIM                                               !0, 102
   59     4        OP_DATA                                                  <array>
   65     5        ASSIGN_DIM                                               !0, 103
   66     6        OP_DATA                                                  <array>
   72     7        ASSIGN_DIM                                               !0, 104
   73     8        OP_DATA                                                  <array>
   79     9        ASSIGN_DIM                                               !0, 105
   80    10        OP_DATA                                                  <array>
   86    11        ASSIGN_DIM                                               !0, 106
   87    12        OP_DATA                                                  <array>
   93    13        ASSIGN_DIM                                               !0, 107
   94    14        OP_DATA                                                  <array>
  100    15        ASSIGN_DIM                                               !0, 108
  101    16        OP_DATA                                                  <array>
  107    17        ASSIGN_DIM                                               !0, 109
  108    18        OP_DATA                                                  <array>
  114    19        ASSIGN_DIM                                               !0, 110
  115    20        OP_DATA                                                  <array>
  121    21        ASSIGN_DIM                                               !0, 111
  122    22        OP_DATA                                                  <array>
  128    23        ASSIGN_DIM                                               !0, 112
  129    24        OP_DATA                                                  <array>
  135    25        ASSIGN_DIM                                               !0, 113
  136    26        OP_DATA                                                  <array>
  142    27        ASSIGN_DIM                                               !0, 114
  143    28        OP_DATA                                                  <array>
  149    29        ASSIGN_DIM                                               !0, 115
  150    30        OP_DATA                                                  <array>
  156    31        ASSIGN_DIM                                               !0, 116
  157    32        OP_DATA                                                  <array>
  163    33        ASSIGN_DIM                                               !0, 117
  164    34        OP_DATA                                                  <array>
  170    35        ASSIGN_DIM                                               !0, 118
  171    36        OP_DATA                                                  <array>
  177    37        ASSIGN_DIM                                               !0, 119
  178    38        OP_DATA                                                  <array>
  184    39        ASSIGN_DIM                                               !0, 120
  185    40        OP_DATA                                                  <array>
  191    41        ASSIGN_DIM                                               !0, 122
  192    42        OP_DATA                                                  <array>
  198    43        ASSIGN_DIM                                               !0, 123
  199    44        OP_DATA                                                  <array>
  205    45        ASSIGN_DIM                                               !0, 124
  206    46        OP_DATA                                                  <array>
  212    47        ASSIGN_DIM                                               !0, 125
  213    48        OP_DATA                                                  <array>
  219    49        ASSIGN_DIM                                               !0, 126
  220    50        OP_DATA                                                  <array>
  226    51        ASSIGN_DIM                                               !0, 127
  227    52        OP_DATA                                                  <array>
  233    53        ASSIGN_DIM                                               !0, 128
  234    54        OP_DATA                                                  <array>
  240    55        ASSIGN_DIM                                               !0, 129
  241    56        OP_DATA                                                  <array>
  247    57        ASSIGN_DIM                                               !0, 130
  248    58        OP_DATA                                                  <array>
  254    59        ASSIGN_DIM                                               !0, 131
  255    60        OP_DATA                                                  <array>
  261    61        ASSIGN_DIM                                               !0, 132
  262    62        OP_DATA                                                  <array>
  269    63      > FE_RESET_R                                       $35     !0, ->70
         64    > > FE_FETCH_R                                       ~36     $35, !1, ->70
         65    >   ASSIGN                                                   !2, ~36
  270    66        FETCH_DIM_W                                      $38     !0, !2
         67        ASSIGN_DIM                                               $38, 'sku'
         68        OP_DATA                                                  !2
  269    69      > JMP                                                      ->64
         70    >   FE_FREE                                                  $35
  273    71      > RETURN                                                   !0
  274    72*     > RETURN                                                   null

End of function get_products_all

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
154.13 ms | 1408 KiB | 15 Q