Re: PHP Variables across files
| From: | Ben Peter | Date: | Tue, 20 Feb 2001 09:38:46 +0000 |
| Subject: | Re: PHP Variables across files | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-40724@lists.php.net to get a copy of this message | ||
Jay,
to make variables.inc available from wherever you are, set the value of
include_path in your php.ini or httpd.conf or .htaccess t something like
".:/path/to/where/variables.inc/is:/other/paths"
as an alternative, use the auto_prepend_file directive to include
variables.inc before any script.
See the 'configuration' section in the php manual on how to do this.
Cheers,
Ben
Jay Klehr wrote:
>
> Hey all,
>
> I have a question about using a variable across multiple PHP files.
>
> I want to set a path variable such as: $root_path = /www2/yoursite/docs
>
> and I want this variable to be able to be changed in case the site is moved
> to another server that has a different root path.
>
> I was thinking that I could put this variable into another include file,
> such as variables.inc and then include or require this file in the script.
> However, what if these multiple PHP files that will use this variable are
> spread across multiple directories? I can't really just do this:
> include("variables.inc") because variables.inc won't be in the same
> directory as that particular PHP file. So once again I am presented with
> the same problem of telling these PHP scripts where to look for files.
>
> Is there a simple solution in PHP that I am overlooking? Some sort of
> cross-PHP file GLobal variable I can set or something? =)
>
> I'm REALLY new at PHP, but fairly knowledgeable in PERL, so I'm still trying
> to make the switch over.
>
> Thanks in advance for any help that you can provide, and I hope I can
> participate a lot on this list.
>
> Thanks again,
>
> Jay Klehr
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
> For additional commands, e-mail: php-general-help@lists.php.net
> To contact the list administrators, e-mail: php-list-admin@lists.php.net