![]() Preserved Topic: Ack... including a php (Page 1 of 1) |
|
---|---|
Bipolar (III) Inmate From: Detroit, MI US |
![]() I was wondering if there would be a way for me to include php files in an html file without saving the html file with an extension of .htm or .html. |
Bipolar (III) Inmate From: |
![]() I think you can tell your server to parse any type files as anything. code: # AddType allows you to tweak mime.types without actually editing it, or to
code: AddType application/x-httpd-php .php .phtml .html .htm
|
Lunatic (VI) Mad Scientist From: Massachusetts, USA |
![]() Keep in mind that if you do this, there are security issues to think of: any place a user can add HTML to a page (like a forum or something) might let them put PHP in there. Ads might also be a concern. So think carefully of all the possible abuses. |
Paranoid (IV) Inmate From: Behind the Wheel |
![]() that's what i was going to say... i've done that on my own local server and it worked fine... |
Maniac (V) Mad Scientist From: 100101010011 <-- right about here |
![]() You should be able to use a normal virtual include to do this though it will depend on your server configuration. |
Obsessive-Compulsive (I) Inmate From: Somewhere in Iowa |
![]() Time for an alternative. Here's one way to add a PHP driven element to a static page, but it'll require the end user to be using Javascript to see it. Have the PHP section of the page loaded via Javascript, and have the Javascript use the Document.write() function to output the content on the page. code: <SCRIPT LANGUAGE="JavaScript" SRC="somescript.php"></SCRIPT>
code: $output = str_replace("\"","\\"."\"", $output);
code: <SCRIPT LANGUAGE="JavaScript">
code: header("Content-type: application/x-javascript");
|
Bipolar (III) Inmate From: Detroit, MI US |
![]() Hey, those are all great suggestions! Which one do I pick... I'm like a kid in a candy store. |