|
Posted by Jerry Stuckle on 01/20/07 19:49
Toby Inkster wrote:
> Jerry Stuckle wrote:
>
>> $_SERVER['DOCUMENT_ROOT'] will ALWAYS contain the absolute path to the
>> root directory of your site, no matter where it is. You need to make no
>> changes to any files when referencing this way.
>
> Makes it tricky to move your PHP around *within* your document root
> though. I try to make my code run equally well rooted in "/somedir/" as it
> does in "/".
>
Sure. But I almost never do that. And if I do, I can quickly do a
search/replace for the file path. On a 3K+ file site it takes less than
a minute to replace all of the references.
> Putting everything in an 'includes' directory and then specifying the
> location of the files in include_path allows you to easily move the
> includes anywhere (including outside the document root altogether, which
> is often desirable from a security POV) without making any changes to your
> scripts at all.
>
Sure - if you're on Apache, if you have .htaccess, if your host allows
PHP changes to .htaccess...
And files can be outside of the document root with this means, also - i.e.
$_SERVER['DOCUMENT_ROOT'] . '/../passwords.txt'
would be the file 'passwords.txt' one level below the document root.
And again - search/replace changes the scripts just fine. Use the right
tools and you don't need gimmicks.
>> Then you don't need any entry in your .htaccess file (which even Apache
>> recommends against using), you don't have to worry about setting it up
>> or anything else. Everything works automatically.
>
> Better to use "httpd.conf" or "php.ini" for such settings, but not
> everyone is able to. I tend to use ".htaccess" for testing and then
> migrate to "httpd.conf" once I'm sure.
>
Again - what if you're on an IIS system? No .htaccess. What if your
hosting company has restricted you so that PHP cannot load values from
..htaccess? I've found several who do.
>> And BTW - it works in IIS also, which doesn't have a .htaccess file.
>> Works great, in fact.
>
> As does "include_path" -- you just need to set it in php.ini.
>
Which is impossible on a shared host. Not everyone has access to or
needs a dedicated server or a vps.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
[Back to original message]
|