Re: Too much of $GLOBALS[] a problem??

From: Date: Fri, 18 Jul 2003 02:58:47 +0000
Subject: Re: Too much of $GLOBALS[] a problem??
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-155716@lists.php.net to get a copy of this message
Ow Mun Heng <ow.mun.heng@wdc.com> wrote: > Hi All, > > Just a quick question on this. In my scripts, I'm using A LOT Of > $GLOBALS['my_parameter'] to get the declared values/string. 1 example below > : > > function display_menu_html() > { > echo '<table class="width100" > cellspacing="0">'."\n"; > echo '<tr>'."\n"; > echo "\t".'<td class="menu">'."\n"; > echo "\t".'<a href="home.php">' . > $GLOBALS['home'] . "</a> > > [...] > > } > > This isn't really a Problem but.. is it bad programming practice?? Or I > should just write another function that can return the values/string? yes and no, that is rather a debatable question. To make my functions that echo stuff cleaner I usually do stuff like: function show_html() { <? <table class="width100" cellspacing="0"> <tr> <td class="menu"> <a href="someplace.php"><?php echo $var?></a> </td> </tr> </table> ?> }

« previous php.general (#155716) next »