Reply to Re: Export local variable to global variable scope?

Your name:

Reply:


Posted by howa on 09/29/07 17:29

>> you 'll have problems if you call the function twice.

this can be solved by using include_once.

the reason of using function call to include is we want to selectively
include the needed files, prevent include useless files (i.e. factory
method?)


On 9 29 , 9 10 , Jerry Stuckle <jstuck...@attglobal.net> wrote:
> howa wrote:
> > Hello,
>
> > I have a function, e.g.
>
> > function foo() {
> > include("bar.php");
> > }
>
> > and the bar.php contain contents e.g.
>
> > $global_v1 = "abc";
> > $global_v2 = "def";
>
> > I want to execute function foo(), but at the same time, let the
> > variables declared in bar.php to have global scopem is it possible?
>
> > Thanks.
>
> You should not have an include within a function call. Among other
> things, you 'll have problems if you call the function twice.
>
> Actually, globals are bad things to use, anyway.
>
> --
> ==================
> Remove the "x" from my email address
> Jerry Stuckle
> JDS Computer Training Corp.
> jstuck...@attglobal.net
> ==================

[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

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