Forum Moderators: coopster
but the constant I'm talking about is a base url that should be available to scripts deep in a directory structure. so I can't use include()
so how can I make that constant just always there whenever a script uses it?
php_value auto_prepend /path/to/file
that's what I'm trying to do. I want to use the global constant (the site's root url) as a base for all links and includes and stuff.
ex:
$baseurl = "www.schmuck.com/horatio/fava"
so even if I'm in a script in the "www.schmuck.com/horatio/fava/wonk/special/glob/" directory, I can call "www.schmuck.com/horatio/fava/dog/stuff.php" by saying
include("$baseurl/dog/stuff.php");
I'm sorry, maybe it's just a simple thing I'm not thinking of, but do you know what I'm saying now? How would I do what I'm trying to do?
so even if I'm in a script in the "www.schmuck.com/horatio/fava/wonk/special/glob/" directory, I can call "www.schmuck.com/horatio/fava/dog/stuff.php" by sayinginclude("$baseurl/dog/stuff.php");
That should work just fine but you must specify a protocol ("http://www.example.com/horatio....").
There are two improvements you can and should make, though.
For SPEED use the file system, not the web server
include("/home/htdocs/animals/dogs.php");
For PORTABILITY set a constant based on he server-determined document root
define('DOC_ROOT', $_SERVER['DOCUMENT_ROOT'] . "/animals/");
include(DOC_ROOT . "dogs.php");
this will make it so that all your includes will default to widgets.com/b_site/include/
put that in a folder called include in your includes folder.
then at the top of your page put
<? include ($_SERVER['DOCUMENT_ROOT'].'/b_site/include/config.php');?>
and every other include on the page will just need to be
<? include ('header.php');?>
hope that makes sense