Forum Moderators: coopster

Message Too Old, No Replies

Do server side includes work in php?

         

tresmom5

7:50 pm on Sep 23, 2004 (gmt 0)

10+ Year Member



I am a real newbie to php and I set up a page, but I wanted to use server side includes. Is there a way to do this with php? Or does it work and I did something wrong? My includes are not showing up. Very frustrating. Any ideas?

Teresa

kumarsena

8:03 pm on Sep 23, 2004 (gmt 0)

10+ Year Member



php.net/include

coho75

8:08 pm on Sep 23, 2004 (gmt 0)

10+ Year Member



<?php
include "path/to/file";
?>

This is the standard way to include a file in PHP. Hope this helps.

coho75

coopster

8:12 pm on Sep 23, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Yes, Apache server-side includes work in files processed by the PHP parser, but as kumarsena pointed out, the includes function should cover you fairly well. If you truly want to process Apache server-side includes in
.php
files, you need to make sure your configuration file (
httpd.conf
) or per-directory override file (
.htaccess
) contains the following directives:
Options +Includes 
AddOutputFilter INCLUDES .php

encyclo

8:14 pm on Sep 23, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



PHP includes work in a slightly different way to SSI in that you have to specify the full path from the server root to the file, rather than just from the document root (web root) as in SSI.

The best way to get around this and make your code more portable is to do the include like this:

<?php include($_SERVER["DOCUMENT_ROOT"]."/path/to/file.inc.php");?>

tresmom5

9:56 pm on Sep 23, 2004 (gmt 0)

10+ Year Member



Thank you! Thank you! Thank you! I knew there had to be a way to do it. Hopefully, eventually I will be able to give help here and not just ask advice.

Teresa

jatar_k

10:30 pm on Sep 23, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



>> Hopefully, eventually I will be able to give help here and not just ask advice.

hehe, no worries tresmom5. I remember a lot of the members that now give advice asking their first php/mysql questions.

though I think my first post to these boards was about being banned from google ;)