IIS supports HTML to execute PHP output

Source: Internet
Author: User
Tags web hosting

IIS supports HTML to execute PHP output

2012-07-25 10:50:23| Category: PHP| Report | Font size Subscription

There is a simple PHP random number in HTML that needs to be output, for example: <td background= "/images/swt1_02.gif" width= "239" height= "<ul" > Style= font-si ze:14px; Color: #FFF; width:220px; height:27px; line-height:27px; margin-left:10px; "><li> currently has <span style=" FONT-SIZE:14PX; Font-weight:bold; Color: #FF0; "   ><?php echo rand (9,99); ?></span> patient is communicating with Doctor </li></ul> </td> found PHP statement not executed (default itself is not performed), between my server is iis7+php architecture, Make the following modifications: The Internet Information Services (IIS) Manager, handler mappings, add module mappings, such as, OK reboot, ok! Additional: If it is the case of Apache 1, modify httpd.conf, command Apache to HTML as PHP,

The http.conf file in the server needs to be modified.
In Apache httpd.conf, add the following statement:

AddType application/x-httpd-htm. htm
Action application/x-httpd-htm "/php4/php.exe"

General web Hosting, we cannot modify httpd.conf, but we can do it by modifying the. htaccess.
2, modify. htaccess

NEW PHP ADD handlers

Solutionif you need a add handler for PHP * Use the following:

#PHP5

AddHandler application/x-httpd-php5. html. htm

#PHP4

AddHandler application/x-httpd-php4. html. htm

That's if you need to parse. html files, or any of the other extension as PHP, can place this in your. htaccess file.
Description: The above method is to tell the server, what suffix of the file, just call the PHP engine to explain, the browser can directly output the PHP engine, which will reduce the efficiency, not recommended to use.  Attach Other solutions:Before in the HTML page want to do a bit of dynamic things, are using the IFRAME framework inserted, it feels very unsatisfactory. Today do 426Space login part of the time, need to run PHP in index.html to determine the login process, so Baidu and Google for a long time, no solution found, and then from the DZ forum to get a thought, using JS technology to achieve. As follows:

First, the PHP program to write to an external PHP file, and then do the output of JS and PHP combined with the output, the program example is as follows:
<?php
$uid = $_cookie["MyName"];
if (!empty ($uid)) {
Print <<<end
document.write (' END;
} else {
Print <<<end
document.write (' END;
}
?>
Next, insert the following JS code in the HTML page where you need to place the program:

<script src= "C.php?rand={eval echo rand (1, 999999)}" type= "Text/javascript" language= "JavaScript" ></script >

(where c.php is just above the file store name)

This allows you to run the dynamic program in the HTML page. In ASP, ASP. NET can also use this kind of idea.

In addition, the JS output may be normal under IE, and Firefox and Google will automatically refresh the entire page only output random number exists, can be resolved by the following JQ method: <script src= "/images/js/j.js" language= "JavaScript" Type= "Text/javascript" ></script>  <li> currently has <span style= "FONT-SIZE:14PX; Font-weight:bold; Color: #FF0; "id=" SC1 "> <script language=" javascript "type=" Text/javascript ">   var aa=math.floor ( Math.random () *100+1); $ ("#sc1"). HTML (AA); </script> </span> patients are communicating with the Doctor </li>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.