3v4l.org

run code in 300+ PHP versions simultaneously
<?php if(isset($_GET['action'])){ if ($_GET['action']=='empty'){ $url="index.php"; if(isset($_SESSION['cart'])){ echo "<h1>Emptying Cart</h1>"; unset($_SESSION['cart']); goto endoption; } goto endoption; } if($_GET['action']=='imgremove'){ $url="index.php?page=cart"; foreach($_SESSION['cart'] as $key=>$value){ foreach($value as $subkey=>$subvalue){ if($subvalue==$_GET['pic']){ unset($_SESSION['cart'][$key]); if(count($_SESSION['cart'])=='0'){ unset($_SESSION['cart']); } goto endoption; } } } } if($_GET['action']=='itemremove'){ $url="index.php?page=cart"; foreach($_SESSION['cart'] as $key=>$value){ foreach($value as $subkey=>$subvalue){ if($subvalue==$_GET['pic']){ foreach($_SESSION['cart'][$key]['details'] as $dkey => $dvalue){ foreach($dvalue as $detail){ if($detail==$_GET['option']){ unset($_SESSION['cart'][$key]['details'][$dkey]); if(count($_SESSION['cart'][$key]['details'])=='0'){ unset($_SESSION['cart'][$key]); } if(count($_SESSION['cart'])=='0'){ unset($_SESSION['cart']); } goto endoption; } } } } } } } } else{ if($_GET['currentpage']=='cart'){ $url="index.php?page=cart"; } else{ $url="index.php?page=".$_GET['currentpage']."&location=".$_GET['location']."&venue=".$_GET['venue']."&session=".$_GET['session']."&pic=".$_GET['pic']; } if (!isset($_SESSION['cart'])) { $_SESSION['cart'][] = array( "pic" => $_POST['pic'], "details" => [] ); $_SESSION['cart'][0]['details'][]= array( "option" => $_POST['option'], "quantity" => $_POST['quantity'] ); goto endoption; } else{ foreach($_SESSION['cart'] as $key=>$value){ foreach($value as $subkey=>$subvalue){ if($subvalue==$_POST['pic']){ foreach($_SESSION['cart'][$key]['details'] as $dkey => $dvalue){ foreach($dvalue as $detail){ if($detail==$_POST['option']){ if($_POST['quantity']=='0'){ unset($_SESSION['cart'][$key]['details'][$dkey]); if(count($_SESSION['cart'][$key]['details'])=='0'){ unset($_SESSION['cart'][$key]); if(count($_SESSION['cart'])=='0'){ unset($_SESSION['cart']); } } goto endoption; } else{ $_SESSION['cart'][$key]['details'][$dkey]['quantity']=$_POST['quantity']; goto endoption; } } } } $_SESSION['cart'][$key]['details'][]=array( "option"=> $_POST['option'], "quantity" => $_POST['quantity'] ); goto endoption; } } } $_SESSION['cart'][] = array( "pic" => $_POST['pic'], "details" => [] ); foreach($_SESSION['cart'] as $key=>$value){ foreach($value as $subkey=>$subvalue){ if($subvalue==$_POST['pic']){ $_SESSION['cart'][$key]['details'][]= array( "option" => $_POST['option'], "quantity" => $_POST['quantity'] ); } } } goto endoption; } } endoption: header("Location: $url"); die();
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.19, 8.3.0 - 8.3.7
Warning: Undefined array key "currentpage" in /in/EIVeE on line 53 Warning: Undefined array key "currentpage" in /in/EIVeE on line 57 Warning: Undefined array key "location" in /in/EIVeE on line 57 Warning: Undefined array key "venue" in /in/EIVeE on line 57 Warning: Undefined array key "session" in /in/EIVeE on line 57 Warning: Undefined array key "pic" in /in/EIVeE on line 57 Warning: Undefined array key "pic" in /in/EIVeE on line 61 Warning: Undefined array key "option" in /in/EIVeE on line 65 Warning: Undefined array key "quantity" in /in/EIVeE on line 66 Warning: Cannot modify header information - headers already sent by (output started at /in/EIVeE:53) in /in/EIVeE on line 121
Output for 5.4.0 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.40, 7.0.0 - 7.0.33, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.31, 7.4.0 - 7.4.33
Notice: Undefined index: currentpage in /in/EIVeE on line 53 Notice: Undefined index: currentpage in /in/EIVeE on line 57 Notice: Undefined index: location in /in/EIVeE on line 57 Notice: Undefined index: venue in /in/EIVeE on line 57 Notice: Undefined index: session in /in/EIVeE on line 57 Notice: Undefined index: pic in /in/EIVeE on line 57 Notice: Undefined index: pic in /in/EIVeE on line 61 Notice: Undefined index: option in /in/EIVeE on line 65 Notice: Undefined index: quantity in /in/EIVeE on line 66 Warning: Cannot modify header information - headers already sent by (output started at /in/EIVeE:53) in /in/EIVeE on line 121
Output for 7.3.32 - 7.3.33

preferences:
234.56 ms | 401 KiB | 378 Q