Detach PHP from HTML, write PHP code in HTML

Source: Internet
Author: User

Files that have both PHP code and HTML code must end with ". PHP".

In order for the PHP interpreter to ignore the HTML code, PHP only processes the contents between a pair of PHP start and end tags.

Such as:

 is ' While the is going to be parsed. ';? ><p>this'll also be ignored by PHP and displayed by the browser.</p>

When PHP encounters the "<?php" tag, it starts parsing, and when it encounters "?>", it ends the parsing. The rest of the code is kept intact.

In this case there is only one PHP start and end tag, and if there are multiple sets of PHP tags, will the code between the two sets of PHP tags remain original?

Such as:

if true):?>  ifistrue. else:?>  This'll  show. <?php endif;?>

The code above will only output "This would show if expression is true" or "Otherwise this will show", while the other is ignored. You can see that the output PHP will automatically skip the paragraphs that are not reached in the conditional statement.

PHP type start and end flags four different ways of writing:

1 <?php?>

2 <script language= "PHP" > </script>

3 <? ?>

4 <%%>

1 or 22 of these methods are always available.

Mode 3 is a segment marker, Method 4 is ASP style and must be configured in php.ini when used

short_oepn_tag= true supports identifying short marks,

Asp_tags=true support for identifying ASP-style tags

It is generally recommended to use 1 or 2 in order to maintain code portability.

Detach PHP from HTML, write PHP code in HTML

Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

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.