Copy link to clipboard
Copied
Hi,
<?php include ('/includes/_header.php'); ?>
...doesn't work, presumably because PHP believes the root directory to be "/home/user/domain/etc" instead of simply "domain"
I'm a bit new to PHP, but wouldn't the "basedir" attribute fix this? And if so, how would it be used in this context, so that Dreamweaver can continue to recognize where the files are located without a testing server needed, and root-relative paths can be used on the server itself?
Thanks!
Copy link to clipboard
Copied
Try
<?php include($_SERVER['DOCUMENT_ROOT'].'/includes/_header.php'); ?>
$_SERVER['DOCUMENT_ROOT'] is not supported by all servers (e.g. a Windows server running in CGI mode) but it's a useful first step. But try it and see.
Copy link to clipboard
Copied
Thanks, but I specifically avoid $_SERVER['DOCUMENT_ROOT'] because Dreamweaver doesn't know what to do with it locally. It requires configuring a formal testing server, which I don't want to do.
Right now, I am editing my HTML/PHP files locally, then uploading those files to server. When editing locally with SPLIT or DESIGN view, DW does a good job of putting all the includes where they should go -- even when using root-relative paths -- but those root-relative paths result in "not found" errors once on the server (for reasons explained in the OP).
Document-relative paths (ie, "../../file.php") work on both the local machine AND the server. But I'd rather NOT use doc-relative paths if at all possible.
If "basedir" does what I suspect it does, then I think I may be able to have my cake (use root-relative paths) and eat it too (have those root-relative paths work on the server too).
Please let me know if I'm being in any way confusing.
Copy link to clipboard
Copied
I'm afraid I don't know of any other way of using root relative links locally in PHP other than with $_SERVER['DOCUMENT_ROOT']
and a local testing server.
Any particular reason you're not using a local testing server?
There are other PHP experts on this forum who will know more.
Copy link to clipboard
Copied
mjyeager wrote:
I'm a bit new to PHP, but wouldn't the "basedir" attribute fix this?
No. PHP include commands require one of the following:
Nothing else will work.