Forum Moderators: coopster

Message Too Old, No Replies

Server side includes

What extension should I use for a .php page?

         

bouncybunny

3:03 am on Mar 31, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Probably a stupid question, but I'm not really a coder, so please bear with me.

I have a series of static html pages with a .PHP extension. The reason for this is that some other dynamic part of the site requires it for includes.

Anyway, I am about to include some separate ssi elements in these pages. Thing is, I have found that using the .SSI extension on these includes seems to work just fine when I use the following code - which Dreamweaver was kind enough to generate for me. ;)

<?php require_once('../../subdirectory/thisfile.ssi');?>

But I'm wondering whether I should be using a .php extension for these includes. E.G.
<?php require_once('../../subdirectory/thisfile.php');?>

Is there any reason why I should be using one over the other?

Thanks.

netfiends

6:45 am on Mar 31, 2007 (gmt 0)

10+ Year Member



I don't believe there is. I pref to keep my includes as .php as that allows me to use php in the includes [if I wanted to] without having to modify more code.

bouncybunny

7:04 am on Mar 31, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Thanks.

So, for the sake of future proofing, I may be better off using .php?

netfiends

7:17 am on Mar 31, 2007 (gmt 0)

10+ Year Member



IMO, yes. I also pref include_once over require_once [unless you want the script to die/error if it isn't able to require the file].

bouncybunny

9:13 am on Mar 31, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Thanks.

jatar_k

1:39 pm on Apr 1, 2007 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



you definitely don't want to change extensions on existing, spidered, pages

if it is only for includes then it doesn't matter

but..

I always prefer to have a php extension as then if someone did call that file on it's own it would still get parsed and not show the code. Though you could just add .ssi in httpd.conf to be parsed by php.

For included files I often use .inc.php then I know that those are included files that are not used individually.

As long as you figure out a naming convention and stick to it then you'll be fine.

bouncybunny

3:26 pm on Apr 2, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Thanks. Very useful.

Oh it's not for spidered pages. Just for the include files themselves.