Support Forums

Full Version: [TRICK] Write php codes inside .html files
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
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
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.
Good job kab012345! zone NonoNono
(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.
(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
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.
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.
Thanks this post actually taught me something ^^
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.
(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!
Pages: 1 2