What's the Variable for Domain Root? Or a Way to go up a Directory?
So first check out my line of code below:
$env_config['tmpl_file_basepath'] = DOC_ROOT . '/tpl/';
DOC_ROOT is equal to $_SERVER['DOCUMENT_ROOT'] which is equal to /var/www/example.com/html/
So my code above would set that path to: /var/www/example.com/html/tpl/
However the tpl folder should actually be in /var/www/example.com/
So first is there any server variable that is equal to the domain root, rather than the public directory root? And if not, is there a way to go up a diretory such as:
$env_config['tmpl_file_basepath'] = DOC_ROOT . '../tpl/';
I tried that but instead it just did /var/www/开发者_如何学JAVAexample.com/html/../tpl/
If this site was just in one location, I could simply manually type in the server path, but this is a config file that is used on local, dev, and live so I can't have it hardcoded. I've gotten everything else working. Thank you!
To go up one directory, you can use dirname:
$env_config['tmpl_file_basepath'] = dirname(DOC_ROOT) . '/tpl/';
/path/to/some/../location
is equal to /path/to/location
, because ..
references the parent directory. You can use realpath()
to resolve the path to its canonical form, but usually this is not necessary.
You could try using realpath to get the absolute path to the tpl dir.
$env_config['tmpl_file_basepath'] = realpath(DOC_ROOT . '../tpl/');
Did you try ussing /tpl because / would make you end up in your webdir if i'm not mistaking. Or do you want the tpl dir outside of the webroot?
精彩评论