Example code for embedding PHP in HTML

Source: Internet
Author: User
1. Embed PHP into HTML

PHP is an embedded language that can be used in combination with HTML, but in thousands of code, however, how to differentiate between HTML and PHP, PHP decomposition (tags) as pillar, exactly the beginning and end of the PHP script. There are four types of decomposition characters that allow PHP to be embedded in HTML.

(1) <?php and >:php standard decomposition.

(2) <,? and?: Shorthand for the decomposition of the character.

(3) <script language= "PHP" > and </script>:javascript/vbscript style decomposition characters

(4) <% and%>:asp decomposition characters.

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

Note: To use PHP to support < ><%%>, the following settings need to be set in the configuration file php.ini, respectively:

Short_open_tag = on;

Asp_tags = on;

The content between a pair of decomposition characters "<" and ">" is PHP code, except that the inner wing is an element of HTML.

Terminator of PHP statements

The statement terminator in PHP is a semicolon ";", that is, after each sentence of PHP code, you need to add ";" to indicate the end of the statement.

PHP is case sensitive, ignoring whitespace in the statement, tabs, carriage returns, which can make the program have a good indentation style.

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.