wampthing Posted May 28, 2005 Posted May 28, 2005 If you look under apache handlers you see that SHTML pages are capable of hadling Includes (which is how I do mine). You can also set it up so that .html and .htm pages can handle includes. Is there a down side to doing this? It sure seems easy to stick with html instead of PHP or SHTML. Quote
TCH-Bruce Posted May 28, 2005 Posted May 28, 2005 Don't know if there is a downside. I thought I read a while back on the forums that someone couldn't mix SHTML and PHP. However you can use PHP includes to do everything you are doing now and it works in HTML files just fine. Quote
wampthing Posted May 28, 2005 Author Posted May 28, 2005 So the main page can be in HTML and the include is a PHP file? Is that how it works or visa-versa Quote
TCH-Bruce Posted May 28, 2005 Posted May 28, 2005 That is correct. Take a look at the manual for the include function. My site is all HTML and I use PHP includes for navigation and footers. Quote
wampthing Posted May 28, 2005 Author Posted May 28, 2005 Ok, so I tried making an html page with a php include but I am having problems. http://myjensen.com/new.html if you look at the source it shows three different attempts at getting it, but none show up. any Ideas? Quote
TweezerMan Posted May 28, 2005 Posted May 28, 2005 If you look under apache handlers you see that SHTML pages are capable of hadling Includes (which is how I do mine). You can also set it up so that .html and .htm pages can handle includes. Is there a down side to doing this? It sure seems easy to stick with html instead of PHP or SHTML. <{POST_SNAPBACK}> The Apache manual recommends against configuring the server to parse .html and .htm pages for server-side includes: ...by doing this, you're requiring that Apache read through every single file that it sends out to clients, even if they don't contain any SSI directives. This can slow things down quite a bit, and is not a good idea. What is recommended instead is to use the XBitHack directive in your .htaccess file: >XBitHack on With XBitHack enabled in your .htaccess file, you can have specific .html pages parsed for server-side includes by setting the permissions on those files to be executable. Quote
wampthing Posted May 28, 2005 Author Posted May 28, 2005 WOW, Talk about pealing an onion. Ill see if I can figure it out. Quote
TCH-Bruce Posted May 28, 2005 Posted May 28, 2005 Sorry, missed one critical piece of information. For PHP to be parsed in HTML pages you need to add this to your .htaccess file. >AddType application/x-httpd-php .htm .html Quote
wampthing Posted May 28, 2005 Author Posted May 28, 2005 Sorry, missed one critical piece of information. For PHP to be parsed in HTML pages you need to add this to your .htaccess file. >AddType application/x-httpd-php .htm .html <{POST_SNAPBACK}> OK I added the code to my .htaccess file, and now instead of getting nothing I get errors. Any Ideas? Quote
TCH-Don Posted May 28, 2005 Posted May 28, 2005 I use Bruces method above as all my html pages are made up of php includes. I also added shtml to the list so my error pages can use php. However SSI will no longer work in the error pages, but I do not care as I use php instead. Quote
TCH-Don Posted May 28, 2005 Posted May 28, 2005 How are you including? include("file"); or include $_SERVER['DOCUMENT_ROOT']."/file"; Quote
wampthing Posted May 28, 2005 Author Posted May 28, 2005 I have tried ><!--#include file="/pool/top.php" --> and ><!--#include virtual="/pool/top.php" --> and ><?php include("/pool/top.php"); ?> Quote
TCH-Don Posted May 28, 2005 Posted May 28, 2005 try include $_SERVER['DOCUMENT_ROOT']."/pool/top.php"; Quote
wampthing Posted May 28, 2005 Author Posted May 28, 2005 (edited) I have tried it all of the following ways ><body> include $_SERVER['DOCUMENT_ROOT']."/pool/top.php" <!--#include file="/pool/top.php" --> <?php include("/pool/top.php"); ?> <!--#include virtual="/pool/top.php" --> </body> no luck Edited May 28, 2005 by wampthing Quote
TCH-Don Posted May 28, 2005 Posted May 28, 2005 <?php include $_SERVER['DOCUMENT_ROOT']."/pool/top.php"; ?> Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.