Why should I write this while loop separately? Why not write it in a php tag? -Php Tutorial

Source: Internet
Author: User
In the picture, why is the ending Mark written in the curly braces at the beginning of the while loop? the ending curly braces at the end of the while loop are separately included by the php tag. why is the independent php tag in the while execution statement? what if I want to write it like this? Include all of these in one & amp; lt ;? Php? & Amp; gt; so...

In the picture, why is the ending Mark written in the curly braces at the beginning of the while loop? the ending curly braces at the end of the while loop are separately included by the php tag. why is the independent php tag in the while execution statement? what if I want to write it like this? Include all of these in one Isn't it possible to write such a label? I often don't know how to write it in this way. can you explain it to me?

Reply content:

In the picture, why is the ending Mark written in the curly braces at the beginning of the while loop? the ending curly braces at the end of the while loop are separately included by the php tag. why is the independent php tag in the while execution statement? what if I want to write it like this? Include all of these in one Isn't it possible to write such a label? I often don't know how to write it in this way. can you explain it to me?

One is PHP code and the other is HTML code. If you want to write HTML code to the PHP code block, you must useechoWrap up the HTML code. But writing the PHP interpreter will automatically process the HTML code in the middle, saving a lot of trouble and making it clear.

Php and html hybrid writing
It must be separated by the start and end characters of the PHP file.
This method is what you met. when you encounter html content, such as while and for, you have to finish it.
Either use html as a string in php


  ***

" }?>

The text outside the php tag is treated as text, so}Is part of php, with 39th rowswhilePairing.
In fact, there can be a more elegant way:Alternative syntax.


      

Some html code

Value $ _ GET ['A'] is

Forif,forAnd other statements.

The template is introduced to avoid splicing html in the code.

This is the html output in php.

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.