Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[TRICK] Write php codes inside .html files
#1
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
Reply
#2
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.
[Image: izsyo6.jpg]


Reply
#3
Good job kab012345! zone NonoNono
Reply
#4
(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.
Reply
#5
(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
[Image: izsyo6.jpg]


Reply
#6
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.
MyBB Support Team Lead
Reply
#7
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.
Reply
#8
Thanks this post actually taught me something ^^
[Image: sig.php]
Reply
#9
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.
Superman I am here to rescue you.
This is Support Forums not Support PMs.  Do not PM me for support unless it's private and site related.
Reply
#10
(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!
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  PHP Framework List: An Ultimate Guide to 102 PHP Frameworks for Web Developers tk-hassan 0 766 07-27-2020, 11:26 PM
Last Post: tk-hassan
  PHP Video Tutorials (PHP For Beginners) Eleqtriq 4 3,253 10-10-2011, 01:00 PM
Last Post: Greyersting
  How to write good php code [Must Read] BannedPoop 19 5,669 08-30-2011, 08:28 AM
Last Post: Slash
  HTML&PHP Games. flAmingw0rm 25 3,401 06-04-2011, 07:23 AM
Last Post: Strafeness
  HTML Website Anon 6 1,936 06-01-2011, 03:26 AM
Last Post: !LoL

Forum Jump:


Users browsing this thread: 1 Guest(s)