Feb 22, 2011

Execute PHP from a .html File


How can I execute PHP code on my existing myfile.html page?:
When a web page is accessed, the server checks the extension to know how to handle the page. Generally speaking if it sees a .htm or .html file, it sends it right to the browser because it doesn't have anything to process on the server. If it sees a .php extension (or .shtml, or .asp, etc), it knows that it needs to execute the appropriate code before passing it along to the browser.
Here is the problem: You find the perfect script, and you want to run it on your site, but you need to included PHP on your page for it to work. You could just rename your pages to yourpage.php instead of yourpage.html, but you already have incoming links or search engine ranking so you don't want to change the file name. What can you do?
First let me preface this by saying that if you are creating a new file anyway, you may as well use .php. This is to help people who have existing .html pages they need to execute PHP on.
The way to execute PHP on a .html page is to modify your .htaccess file. This file may be hidden, so depending upon your FTP program you may have to modify some settings to see it. Then you just need to add this line for .html:
AddType application/x-httpd-php .html
Or for .htm
AddType application/x-httpd-php .htm
If you only plan on including the PHP on one page, it is better to setup this way:
<Files yourpage.html>
AddType application/x-httpd-php .html
</Files>
This code will only make the PHP executable on the yourpage.html file, and not on all of your html pages.
Things to watch out for:
  • If you have an existing .htaccess file, add this to it, do not overwrite it or other settings may stop working! Always be very careful with your .htaccess file and ask your host if you need help
  • Anything in your .html files that starts with <? will now be executed as PHP, so if it's in your file for some other reason (an XML tag for example) you will need to echo these lines to prevent errors. For example:
    <?php echo '<?xml version="1.0" encoding="IUTF-8"?>'; ?>

1 comment:

Unknown said...

不可不知的陽痿早洩宜與忌
提醒:素體虛弱或遺精日久,導致腎陰腎陽俱虛亦可有陽痿早洩。威而鋼哪裡買 犀利士哪裡買 壯陽藥品 壯陽藥 威而鋼哪裡買 犀利士專賣 威而鋼 威而鋼哪裡買 威而鋼專賣店 威而鋼藥局同時一定的心理原因也可發生。 我為大家介紹關於陽痿早洩的宜與忌。
1、新婚初次性交,或夫妻久別重逢所出現的陽痿早洩現象,不能作為病態對待。 等性生活正常後,陽痿早洩現象就會消失。
2、因陰莖包皮繫帶過短等原因造成的陽痿早洩,應去醫院作手術治療。
3、調整情緒,壯陽藥 壯陽藥品 犀利士 威而鋼 威而鋼專賣店 犀利士 犀利士 壯陽藥品 壯陽藥性生活時要做到放鬆。
4、勿縱慾,勿疲勞後行房。
5、男方患有陽痿早洩,女方切勿埋怨責怪,以免加重男方的心理壓力,更不可有性懲罰。
6、加強體育鍛煉,受好廣泛,戒手淫。
7、採用“壓捏”術可延遲射精。 即女方對男方的陰莖給予刺激,快要射精時,婦言再緊緊壓捏住陰莖頭與陰莖桿之間的地方約3~4秒,陰莖勃起狀態會減少10%~30%。 大約過30秒鐘後,夫婦再恢復包括刺激陰莖在內的性戲。 如果男方又覺得要射精了,女方再重複壓捏陰莖的動作。犀利士 犀利士專賣 犀利士哪裡買 犀利士5mg價格 壯陽藥品 犀利士專賣 威而鋼 壯陽藥 威而鋼專賣店 犀利士哪裡買這樣可使性愛前奏的時間長達15~20分鐘而不致射精。 接受這種陽痿早洩治療的人,其治愈率可高達98%左右。