3v4l.org

run code in 300+ PHP versions simultaneously
<?php $bill= 0; $sno = 1; foreach($_SESSION as $products){ //print_r($products); echo "<tr> <form action='edit_cart.php' method='post'>"; if (!$products) $products = array(); foreach($products as $key =>$value){ if($key == 0){ echo "<input type='hidden' name='name$key' class='form-control' value='".$value."'> <td>".$value."</td>"; } else if($key == 1){ $p = $value; echo "<input type='hidden' name='name$key' class='form-control' value='".$value."'> <td>".$value."</td>"; }else if($key == 2){ $q = $value; $bill = ($p * $q); echo "<td><input type='number' name='name$key' class='form-control col-xl-4 text-center' min='1' value='".$value."'></td> <td>".($bill)."</td> <td><input type='submit' name='event' value='Update' class='btn btn-sm btn-warning'></td> <td><input type='submit' name='event' value='Delete' class='btn btn-sm btn-danger'></td>"; } } echo "</form> </tr>"; } echo "</table> </div>"; ?>
Output for 8.1.0 - 8.1.34, 8.2.0 - 8.2.30, 8.3.0 - 8.3.4, 8.3.6 - 8.3.30, 8.4.1 - 8.4.18, 8.5.0 - 8.5.3
Warning: Undefined global variable $_SESSION in /in/SBDRU on line 4 Warning: foreach() argument must be of type array|object, null given in /in/SBDRU on line 4 </table> </div>
Output for 8.3.5
Warning: PHP Startup: Unable to load dynamic library 'sodium.so' (tried: /usr/lib/php/8.3.5/modules/sodium.so (libsodium.so.23: cannot open shared object file: No such file or directory), /usr/lib/php/8.3.5/modules/sodium.so.so (/usr/lib/php/8.3.5/modules/sodium.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0 Warning: Undefined global variable $_SESSION in /in/SBDRU on line 4 Warning: foreach() argument must be of type array|object, null given in /in/SBDRU on line 4 </table> </div>
Output for 8.0.0 - 8.0.30
Warning: Undefined variable $_SESSION in /in/SBDRU on line 4 Warning: foreach() argument must be of type array|object, null given in /in/SBDRU on line 4 </table> </div>
Output for 7.3.0 - 7.3.31, 7.3.33, 7.4.0 - 7.4.25, 7.4.27 - 7.4.33
Notice: Undefined variable: _SESSION in /in/SBDRU on line 4 Warning: Invalid argument supplied for foreach() in /in/SBDRU on line 4 </table> </div>
Output for 7.3.32, 7.4.26
Warning: Invalid argument supplied for foreach() in /in/SBDRU on line 4 </table> </div>

preferences:
111.47 ms | 1412 KiB | 4 Q