> -----Original Message-----
> From: Stuart Dallas [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, June 13, 2002 2:53 PM
> To: Phillip Perry
> Cc: Tim Ward; Martin Towell; Tom Rogers; Php
> Subject: Re[2]: [PHP] beginner in PHP
>
>
> On Thursday, June 13, 2002 at 7:44:39 PM, you wrote:
>
> > Yes, here is the checkout code I used...
>
> > function chout(){
> > session_destroy();
> > unset ($mycart);
> > unset ($cart_items);
> > echo "<p>Thank you for shopping!</p>";
> > }
>
> > Any suggestions?
>
> Try this...
>
> function chout(){
> global $mycart, $cart_items;
> session_destroy();
> unset ($mycart);
> unset ($cart_items);
> echo "<p>Thank you for shopping!</p>";
> }
Still won't work. All that the "global" statement does is make the copy of the
variable inside the function be a *reference* to the global copy -- it's basically
equivalent to
$mycart = & $GLOBALS['mycart'];
So, when you unset($mycart) within the function, all you're unsetting is the reference
-- the actual global variable is completely unaffected. Thus, the only way to unset a
global variable is to reference it in the global context. One way to do this might be:
function chout(){
session_destroy();
unset ($GLOBALS['mycart']);
unset ($GLOBALS['cart_items']);
}
Alternatively, just do it in the global context, outside any function.
Cheers!
Mike
---------------------------------------------------------------------
Mike Ford, Electronic Information Services Adviser,
Learning Support Services, Learning & Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Beckett Park, LEEDS, LS6 3QS, United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php