Hi there,
One of my pet peeves with PHP is that when including files you have to give the relative pathway to the file. With big sites this becomes a drag and I have to remember how many "../../" to add instead of just adding the nice "/path/to/file/php" which is the same for all files.
Has anyone come up with a work around for this glitch?
All help appreciated!
- Tatlaryou can use the full path no problem
"/path/to/file/php"
that should work as I use it all the time.Originally posted by scoutt
you can use the full path no problem
"/path/to/file/php"
that should work as I use it all the time.
Right, you can use the FULL path, but not from the document root that is defined in the Apache httpd.conf file.
For example if I have a document root for a site defined in my httpd.conf file as:
/export/home/apache/htdocs/mysite/
Then if I want to include a file I just type "/includes/files.html" in any shtml file.
whereas with php I have to type:
/export/home/apache/htdocs/mysite/includes/files.html
This is what I meant. Do you see the difference? I guess I could always define a variable as:
$variable = /export/home/apache/htdocs/mysite/
And use that in my PHP files....
Thanks,
- Tatlaryes I see but now you are talking about apache as to were I was talking php. or you can do this
include($_SERVER['DOCUMENT_ROOT']."file.php");
where document_root is the that long pathinclude($_SERVER['DOCUMENT_ROOT']."file.php");
So PHP can read the document root that easily, huh? Well, I did not know that. Thanks Scoutt, and apologies for my poorly worded initial question....
:dunce:
- Tatlar
One of my pet peeves with PHP is that when including files you have to give the relative pathway to the file. With big sites this becomes a drag and I have to remember how many "../../" to add instead of just adding the nice "/path/to/file/php" which is the same for all files.
Has anyone come up with a work around for this glitch?
All help appreciated!
- Tatlaryou can use the full path no problem
"/path/to/file/php"
that should work as I use it all the time.Originally posted by scoutt
you can use the full path no problem
"/path/to/file/php"
that should work as I use it all the time.
Right, you can use the FULL path, but not from the document root that is defined in the Apache httpd.conf file.
For example if I have a document root for a site defined in my httpd.conf file as:
/export/home/apache/htdocs/mysite/
Then if I want to include a file I just type "/includes/files.html" in any shtml file.
whereas with php I have to type:
/export/home/apache/htdocs/mysite/includes/files.html
This is what I meant. Do you see the difference? I guess I could always define a variable as:
$variable = /export/home/apache/htdocs/mysite/
And use that in my PHP files....
Thanks,
- Tatlaryes I see but now you are talking about apache as to were I was talking php. or you can do this
include($_SERVER['DOCUMENT_ROOT']."file.php");
where document_root is the that long pathinclude($_SERVER['DOCUMENT_ROOT']."file.php");
So PHP can read the document root that easily, huh? Well, I did not know that. Thanks Scoutt, and apologies for my poorly worded initial question....
:dunce:
- Tatlar