[Phpwm] An problem with PHP echo

Peter Crouch pccrouch at bcs.org.uk
Mon Feb 20 03:55:47 GMT 2006


Hello to everyone,

As a beginner with Apache and PHP I am hoping someone can explain the 
problem I have encountered.  I hope you will bear with me while I set out 
the background.

I am running Apache, PHP and MySQL under Windows XP Pro with the XAMPP files 
located in the C:/Program Files/xampp tree.

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">

The aliases all appear to work in that the include files, style sheet and 
logo are all read correctly into the webpages.

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');
?>
:
:
<?php
  require('http://localhost/include/footer.php');
?>

In header.php is the following code:

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

In footer.php is the following code:

<?php
      echo "      Last modified: " . $last_mod_date . "\n";
?>

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.

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.

Thank you in advance for any help you can give me.

Peter Crouch
-------------------------------------------------
Tel:    0121 523 6756
E-mail: pccrouch at bcs.org.uk





More information about the Phpwm mailing list