Reply to Re: Don?t unset that variable you need globally

Your name:

Reply:


Posted by Berislav Lopac on 07/06/05 14:41

Tony wrote:
> Berislav Lopac wrote:
>> Even better -- don't use global variables.
>
> Easier said than done. There are times when globals are the best
> solution. There IS a reason they're available...

You can (and should) always pass a global variable as a function parameter.
There is no effective difference between:

function foo($bar)
{
global $foobar;
return $bar + $foobar;
}

and

function foo($bar, &$foobar)
{
return $bar + $foobar;
}

The difference is that when you call the second example you have to pass one
more argument, but that prevents the encapsulation of the function, making
it reusable and independent of the outside world.

Berislav

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация