You are here: Re: using global var (global settings?) « PHP Programming Language « IT news, forums, messages
Re: using global var (global settings?)

Posted by Andy Hassall on 06/19/06 23:19

On 19 Jun 2006 09:56:17 -0700, "Sonnich" <sonnich.jensen@elektrobit.com> wrote:

>I have an app which reads from certain servers, but I'd like to have
>them in am ini-file.
>
>I made this up, but I need those vars to be visible in functions
>too.... how do I do that?

Various options, some of which are:

(1) Access the configuration values through functions instead of globals.
(2) Define them as constants; they're always in scope.
(3) Use the "global" statement in the function.
(4) Reference the variables through $GLOBALS.
(5) It sounds like you want to register your own superglobals - this is not
trivial; runkit can do it, but that's fairly magic and unlikely to be installed
on most servers. http://www.php.net/manual/en/runkit.sandbox.php
--
Andy Hassall :: andy@andyh.co.uk :: http://www.andyh.co.uk
http://www.andyhsoftware.co.uk/space :: disk and FTP usage analysis tool

 

Navigation:

[Reply to this 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

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