PHP Variables across files

From: Date: Tue, 20 Feb 2001 10:31:46 +0000
Subject: PHP Variables across files
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-40723@lists.php.net to get a copy of this message
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

« previous php.general (#40723) next »