PDA

View Full Version : Includes


gsnedders
03-25-2004, 11:46 PM
Can someone tell me all the ways you can do includes (PHP, SSI, ASP etc.) and how to do them, I just want to do this as I am developing a page which has the code to include http://faqs.geoffers.uni.cc/Cro-Mag%20Rally.txt in all the ways which are possible.

liorean
03-26-2004, 12:18 AM
Oldest technology first:
SSI:
<!--#include virtual="path" --> (preferred)
<!--#include file="path" -->

CGI, CMD:
<!--#exec cgi="path" --> (use include virtual instead when you can)
<!--#exec cmd="command" --> (avoid)


ASP Includes, curiously similar to SSI:
<!--#include file = "path" -->
<!--#include virtual = "path" -->

PHP Includes:
<? include("path") ?> (shorttags enabled)
<?php include("path") ?> (shorttags disabled)

XML Includes:
See [XInclude] (http://www.w3.org/TR/xinclude/)

gsnedders
03-26-2004, 12:24 AM
Can you give me an order of which ones to avoid the most please?

liorean
03-26-2004, 12:36 AM
In order of least recommended:
- XML Includes are thus far neither real-world usable nor practical. Don't use them unless you're on an XML technology based server. (IBM, Sun and non-httpd Apache projects, mostly.)

- As for the 'exec cmd', it's both introducing security holes and potential system performance effects. Only use if you're alone on the server and know what you are doing.

- The 'exec cgi' is a bit redundant. You can use 'include virtual' for most of what you could use 'exec cgi', so use 'include virtual' instead, unless the performance gain from using 'exec cgi' is really, really critical.

- The 'include file' is less powerful than 'include virtual'. It has some performance benefits, but in general, you want to use 'include virtual', if for nothing else than consistency reasons.



The SSI parser is faster than the ASP or PHP parsers, so a clean SSI is faster than an ASP or PHP include. However, if you use ASP or PHP in the file already, there's no reason to use SSI as well. Also, if you're using ASP or PHP on the server you can use those includes, and disable the SSI module, to increase server performance overall. This only goes if you have control over the server, though.

gsnedders
03-26-2004, 12:53 AM
Thanks liorean

mordred
03-26-2004, 01:11 AM
Regarding PHP includes:

1.) Don't use shorttags. They aren't supported on every server. <?php tags are.
2.) If you just need the content of the file displayed and don't want PHP to parse it, use readfile() instead.
3.) The speed performance difference between PHP and SSI includes should be very tiny and neglectable.

gsnedders
03-26-2004, 01:23 AM
Originally posted by mordred
Regarding PHP includes:

1.) Don't use shorttags. They aren't supported on every server. <?php tags are.
2.) If you just need the content of the file displayed and don't want PHP to parse it, use readfile() instead.
3.) The speed performance difference between PHP and SSI includes should be very tiny and neglectable.

[list=1]
I never have used shorttags and I don't plan on doing so, I also don't have a clue whether my server supports them
Thanks, that fixed one problem I was having
OK
[/list=1]