3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?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 5.4.0 - 7.2.0
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