Home  >  Article  >  Backend Development  >  Example code embedding PHP in HTML

Example code embedding PHP in HTML

小云云
小云云Original
2018-03-10 10:38:223634browse


1. Embed PHP into HTML

PHP is an embedded language that can be mixed with HTML. However, among thousands of codes, how to distinguish it? As for HTML and PHP, PHP decomposition tags (tags) are like boundary stones, accurately marking the start and end positions of PHP scripts. There are four decomposers that allow PHP to be embedded in HTML.

(1): PhP standard decomposers.

(2): abbreviated decomposition symbols.

(3): JavaScript/VBScript style decomposer

(4)<% and %>: ASP Decomposer.

The first and second methods are the most commonly used; the third method is similar to the JavaScript embedding method; the fourth method is similar to the ASP embedding method.

Note: If you want to use PHP to support the <%%> method, you need to make the following settings in the configuration file PHP.ini:

short_open_tag = on;

asp_tags = on;

The content between a pair of decomposers "<" and ">" is PHP code, and the content outside of it is an HTML element.

Terminator of PHP statement

The terminator of PHP statement is a semicolon ";", that is, after each sentence of PHP code, ";" needs to be added to indicate the end of the statement.

PHP is case-sensitive and ignores spaces, tabs, and carriage returns in statements. This allows the program to have a good indentation style.

Related recommendations:

Detailed introduction to the implementation of PHP obtaining form data and HTML embedding PHP scripts

PHP obtaining form data and HTML Embed PHP script

How to embed PHP code in HTML_PHP tutorial

The above is the detailed content of Example code embedding PHP in HTML. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn