HTML embedded in the PHP code, there is no output content, execution is commented out. What's the reason? I have a local build xamp environment, the file extension from HTML to PHP is not a problem?
For:
PHP can be written in HTML, such as
<body>
<?php echo ' fffffff ';? >
</body>
However, if you insert a PHP statement, you must use the PHP environment to run the HTML file to be effective, such as wampserver.
In addition, the suffix to change the HTML to PHP, because HTML can not parse the content of PHP, unless using the template engine, such as: TP (thinkphp).
When accessing a webpage, the server will determine how to process the page according to the file extension, in general, when checking to the extension of HTM or HTML, the server will directly render the file to the browser side, do not do any processing, if the extension is detected as PHP, shtml, ASP or JSP files, The server first parses the files into HTML code and then renders the code to the process. If you want to be able to run PHP code in an HTML file, you need to modify the Apache configuration file.
First, open the installation directory installed in Apache, which is found under apache\conf: "httpd.conf" file, open with Notepad, and add the following code at the end:
As shown in the following:
Note
(1) After adding the above code, the Apache server must be restarted;
(2) The HTML file must be placed in the Apache configuration file httpd.conf documentroot The specified directory, otherwise it will not run, see
If you only want to include and run PHP scripts in an HTML file, you can set this up:
As shown, where index.html is a file that has been added with PHP code (script), #AddType the # in front of the application/x-httpd-php. htm. html, indicating that the line statement is commented out
Turn from: Mu class quiz Portal
Why does the PHP code embedded in HTML be commented out by the browser?