私のウェブサイトはCareer Tracker です。ローカル マシンのウェブサイトにカートを追加したいのですが、毎回エラーが発生するので疲れました。
私は XAMPP 1.8.1 を使用しました [PHP: 5.4.7] 毎回エラーが発生します Notice: Undefined index: cart in functions.inc.php 4 行目
私のphp veriableが定義されていないのはなぜですか?$cart
これは私のコードで、4 行目でエラーが発生しました。
PHP未定義インデックスエラー
<?php
function writeShoppingCart()
{
$cart = $_SESSION['cart'];
if (!$cart)
{
return 'My Cart (0) Items';
}
else
{
// Parse the cart session variable
$items = explode(',',$cart);
$s = (count($items) > 1) ? 's':'';
return '<a href="cart.php">'.count($items).' item'.$s.' in your cart</a></p>';
}
}
?>