hance2105 Posted June 21, 2013 Share Posted June 21, 2013 hello guys, y am i having an error on this line of code <?php $cartItemCount = count($_SESSION['cart']); ?> do i need to define the 'cart'? how i do it if need be? please Quote Link to comment Share on other sites More sharing options...
Solution boompa Posted June 21, 2013 Solution Share Posted June 21, 2013 (edited) $_SESSION['cart'] = array(); or if (isset($_SESSION['cart'])) $cartItemCount = count($_SESSION['cart']); else $cartItemCount = 0; or, using the ternary operator $cartItemCount = (isset($_SESSION['cart']) ? count($_SESSION['cart']) : 0; Edited June 21, 2013 by boompa Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.