


The html file and the php file have the same content, but the opening effect is different?
<code><html> <head> <meta charset="utf-8"> <title>展示学生资料</title> </head> <body> <?php $name="王六"; ?> <table> <tr> <td>姓名</td> <td><?php echo $name;?></td> </tr> </table> </body> </html> </code>
The above program is saved as test.php and opened with a browser, and the displayed result is as follows
Name Wang Liu
When the above program is saved as test.html, opened with a browser, the displayed result is as follows
Name
The php in it is not parsed ?
Same content, different file types, why are there different results?
Reply content:
<code><html> <head> <meta charset="utf-8"> <title>展示学生资料</title> </head> <body> <?php $name="王六"; ?> <table> <tr> <td>姓名</td> <td><?php echo $name;?></td> </tr> </table> </body> </html> </code>
The above program is saved as test.php and opened with a browser, and the displayed result is as follows
Name Wang Liu
When the above program is saved as test.html, opened with a browser, the displayed result is as follows
Name
The php in it is not parsed ?
Same content, different file types, why are there different results?
Save it as a php file. During parsing, the php engine will parse the php related code. $name will be read by the browser and saved as html. The php code will be automatically ignored because html does not recognize the php code. So there is no value of $name in the end
Suffix identification problem. For PHP, the browser needs to cooperate with the server environment, and the two are processed together. If it is a suffix such as .html, the browser will think that it is a static file in itself and has nothing to do with the server, etc., so it will parse it by itself (actually It is ignored by php and does not reach php to parse). Generally speaking, only php files can contain html code, and cannot be used the other way around
html files will not parse PHP

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

In this chapter, we will understand the Environment Variables, General Configuration, Database Configuration and Email Configuration in CakePHP.

PHP 8.4 brings several new features, security improvements, and performance improvements with healthy amounts of feature deprecations and removals. This guide explains how to install PHP 8.4 or upgrade to PHP 8.4 on Ubuntu, Debian, or their derivati

To work with date and time in cakephp4, we are going to make use of the available FrozenTime class.

To work on file upload we are going to use the form helper. Here, is an example for file upload.

In this chapter, we are going to learn the following topics related to routing ?

CakePHP is an open-source framework for PHP. It is intended to make developing, deploying and maintaining applications much easier. CakePHP is based on a MVC-like architecture that is both powerful and easy to grasp. Models, Views, and Controllers gu

Guide to HTML Table Layout. Here we discuss the Values of HTML Table Layout along with the examples and outputs n detail.

Visual Studio Code, also known as VS Code, is a free source code editor — or integrated development environment (IDE) — available for all major operating systems. With a large collection of extensions for many programming languages, VS Code can be c
