PHP syntax (4)

Source: Internet
Author: User

File: deal. php
<? Php
Echo "your username is: $ uname ";
?> The above program requires the user to enter a user name, submit the form, and then return to the user name to confirm the information. It can be seen that the uname in the form has become the $ uname variable in the deal. php program. Simple. :-)
Let's take a look at the basic process control of PHP:
If... Else... Elseif
Syntax 1:
If (condition ){
Statement body
}
Syntax 2:
If (condition ){
Statement body 1
} Else {
Statement Body 2
}
Syntax 3:
If (condition 1 ){
Statement body 1
} Elseif (condition 2 ){
Statement Body 2
} Else {
Statement body 3
}
We changed the above deal. php program:
<? Php
If ($ uname = "James "){
Echo "nice to see you, James. ";
} Elseif ($ uname = "Xiaohua "){
Echo "oh, it's Xiaohua. ";
} Else {
Echo "you are $ uname, right ";
}
?>
In addition to the if statement, there is a while loop. Its syntax is as follows:
While (condition ){
Statement body
}
When the condition is true, the execution statement body.
Do... The while syntax is as follows:
Do {
Statement body
} While (condition)
Execute the statement body once. If the condition is true, execute the statement body again in a loop.
The syntax of the for Loop is the same as that of C, as shown below:
For (initial condition; judgment condition; condition change) {statement}
The break jumps out of the executing loop, and the continue interrupts this loop.
Okay. Here is the article. I believe you will soon be able to get started with the above basics.

Related Article

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.