View Single Post
  #3 (permalink)  
Old 12-22-2005, 12:02 PM
shawon shawon is offline
Member
 
Join Date: Jun 2005
Posts: 86
iTrader: (0)
Rep Power: 11
shawon is an unknown quantity at this point
Default

Quote:
Originally Posted by nsvr
Hmm, not completly correct, you can use include witouth the (), but the correct way is like:

Code:
<?php include("includes/header.php"); ?>
And i dont recommend to use the full path for includes, just do it like above. If you want to use the full path, use the variable $_SERVER["DOCUMENT_ROOT"], where the /home/username/public_html is already stored in like:

Code:
<?php include($_SERVER["DOCUMENT_ROOT"] . "/includes/header.php"); ?>

And remember if you do that, use superglobals, in this case the super global $_SERVER, although $DOCUMENT_ROOT will also work, but thats for older versions of php.

Another nice thing about php is that you can configure the auto_append_file and auto_prepend_file, with a htaccess file.
This way, php will automatically add at the beginning/end of the php file the header and footer configured by these.
An Adding:

include() is approximately same like the require() but require actually mean, it have to be upto the every refresh on the page.
Reply With Quote