downloads | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links | my php.net 
search for in the  

<CookiesMigrating from PHP/FI 2 to PHP 3>
Last updated: Sat, 29 Oct 2005

Handling of global variables

While handling of global variables had the focus on to be easy in PHP 3 and early versions of PHP 4, the focus has changed to be more secure. While in PHP 3 the following example worked fine, in PHP 4 it has to be unset(unset($GLOBALS["id"]));. This is only one issue of global variable handling. You should always have used $GLOBALS, with newer versions of PHP 4 you are forced to do so in most cases. Read more on this subject in the global references section.

Example C-1. Migration of global variables

<?php
$id
= 1;
function
test()
{
   global
$id;
   unset(
$id);
}
test();
echo(
$id); // This will print out 1 in PHP 4
?>


add a noteadd a note User Contributed Notes
Handling of global variables
There are no user contributed notes for this page.




<CookiesMigrating from PHP/FI 2 to PHP 3>
Last updated: Sat, 29 Oct 2005
show source | credits | sitemap | contact | advertising | mirror sites
Copyright © 2001-2005 The PHP Group
All rights reserved.
This unofficial mirror is operated at: http://phpbuilder.com/
Last updated: Tue Nov 1 20:20:59 2005 EST
Columns / Articles | Tips / Quickies | News | News Linking and RSS Feeds | Shared Code Library
Mail Archives | Support / Discussion Forums | Get Started! Links | Contribute! | Docs