Support Forums
[TRICK] Write php codes inside .html files - Printable Version

+- Support Forums (https://www.supportforums.net)
+-- Forum: Categories (https://www.supportforums.net/forumdisplay.php?fid=87)
+--- Forum: Coding Support Forums (https://www.supportforums.net/forumdisplay.php?fid=18)
+---- Forum: PHP The Hypertext Preprocessor (https://www.supportforums.net/forumdisplay.php?fid=21)
+---- Thread: [TRICK] Write php codes inside .html files (/showthread.php?tid=3126)

Pages: 1 2


[TRICK] Write php codes inside .html files - zone - 11-24-2009

As you know that php and html are quite different from each other. You may enter html codes inside the .php file BUT you can't do such within .html files , i.e., you are unable to write php codes inside .html files.

Here I am sharing you a simple trick to write php codes inside any .html files of your website Smile

Create a blank file and call it .htaccess, you will need to upload this file on your server in the directory where you want to have .html pages containing php code or you can also place the .htaccess file in your site root, the settings inside it will apply to all its sub directories.

Now write the following code inside your .htaccess file and save it:

Code:
AddType application/x-httpd-php .html .htm .php

And you are done ! Now write any php codes inside .html files and the server side language (I mean php) will function correctly. Smile

Enjoy this tip


This tip is shared by zone for www.supportforums.net . If you want to share this, you are free to do so, but please give credit to me.


Thankyou very much and be happy Smile


RE: [TRICK] Write php codes inside .html files - uber1337 - 11-24-2009

um correct me if im wrong but I think you stole that from here
that post was made before this one and please give credit to kab012345

(11-18-2009, 07:35 PM)kab012345 Wrote: You could create a .htaccess file (or add the following code to it):

Code:
<Files index.html>
AddType application/x-httpd-php .html
</Files>

In the HTML file, you can include your script wherever you want it to be displayed.
PHP Code:
<?php include 'status.php'?>

Let me know if this works.



RE: [TRICK] Write php codes inside .html files - Brainless Control - 11-25-2009

Good job kab012345! zone NonoNono


RE: [TRICK] Write php codes inside .html files - zone - 11-25-2009

(11-24-2009, 06:22 PM)uber1337 Wrote: um correct me if im wrong but I think you stole that from here
that post was made before this one and please give credit to kab012345
(11-25-2009, 07:13 AM)Xenocide Wrote: Good job kab012345! zone NonoNono

Believe me, I didn't know about kab012345's post.


RE: [TRICK] Write php codes inside .html files - uber1337 - 11-25-2009

(11-25-2009, 07:33 AM)zone Wrote:
(11-25-2009, 07:13 AM)Xenocide Wrote: Good job kab012345! zone NonoNono

Believe me, I didn't know about kab012345's post.
Seems likely. Only a couple days after he posted you started a thread exactly the same as his post


RE: [TRICK] Write php codes inside .html files - MattR - 11-26-2009

Personally if I wanted to use PHP in the file I'd just name is as .php, and use mod_rewrite to disguise the .php file as .html. You can even disguise it as a .png or .gif or something, just to confuse people.


RE: [TRICK] Write php codes inside .html files - Gaijin - 11-26-2009

And then we come to the conclusion that HTML is to be placed inside of your PHP codes and not PHP in HTML, that just sucks and it's really waste of time.


RE: [TRICK] Write php codes inside .html files - Nyx- - 11-28-2009

Thanks this post actually taught me something ^^


RE: [TRICK] Write php codes inside .html files - Omniscient - 11-29-2009

Personally I like to fake people out entirely if I am going to do this and make the page .asp to really confuse them about what technology I am using.

The htaccess trick is common and it's used often in little graphics scripts or whatnot. It's something webmasters try to avoid though if possible.


RE: [TRICK] Write php codes inside .html files - Gaijin - 12-03-2009

(11-29-2009, 12:22 PM)Omniscient Wrote: Personally I like to fake people out entirely if I am going to do this and make the page .asp to really confuse them about what technology I am using.

The htaccess trick is common and it's used often in little graphics scripts or whatnot. It's something webmasters try to avoid though if possible.

Sure, you're right.
But still writing PHP inside of a HTML code is so.... WRONG, no matter what reasons a coder has!