[Phpwm] An problem with PHP echo

David Goodwin david at codepoets.co.uk
Mon Feb 20 07:35:45 GMT 2006


<snip>
 
> I have DocumentRoot set to "C:/Program Files/xampp/htdocs" in 
> apache\conf\httpd.conf but because I want to build and test a website, 
> www.mydomain.org, on my local machine I have the files located at 
> C:/.../.../.../www.mydomain.org/web/.  On the remote server the /web/ 
> directory corresponds to www.mydomain.org/.
> 
> In order to access the local files I have set the following aliases in 
> httpd.conf:
> 
> Alias /www.mydomain.org "c:/.../.../.../www.mydomain.org/web/"
> <Directory "c:/.../.../.../www.mydomain.org/web">
> 
> Alias /include "c:/.../.../.../www.mydomain.org/web/include/"
> <Directory "c:/.../.../.../www.mydomain.org/web/include">
> 
> Alias /mycss.css "c:/.../.../.../www.mydomain.org/web/mycss.css"
> <Directory "c:/.../.../.../www.mydomain.org/web">
> 
> Alias /mylogo.gif "c:/.../.../.../www.mydomain.org/web/mylogo.gif"
> <Directory "c:/.../.../.../www.mydomain.org/web">
> 

If you have the DocumentRoot set to e.g. c:/program files/xammp/xammp
tree/web (or however it's spelt) the above Aliases should not be needed.

> 
> At the start and end of each .php file I have the following code:
> 
> <?php
>  $page_title = "My page title";
>  $last_mod_date = date("D j M Y H:i:s", getlastmod());
>  require('http://localhost/include/header.php');

<snip>

> <?php
>  echo "<title>" . $page_title . "</title>\n";
> ?>
> 

Can you access http://localhost/include/header.php in a web browser?

> When the require() statements are as above neither of the variables are 
> displayed but if the statements are changed to 
> require('include/header.php'); and
> require('include/footer.php'); then the variables are displayed as expected.
> 

That probably means php is not opening remote files - if you look in the
php.ini there is a directive (something to do with fopen I think) which
determines whether it allows you to do this. 

> Can anyone explaine why the echo statements work in one case and not in the 
> other.  I would like to use the require('http://localhost/include/*.php'); 
> form across all my PHP files whereever they are in the tree structure.

See above (hopefully!)

David.
-- 
David Goodwin 

[ david at codepoets dot co dot uk ]
[ http://www.codepoets.co.uk       ]



More information about the Phpwm mailing list