A brief discussion of PHP syntax (4)_PHP tutorial

WBOY
Release: 2016-07-13 17:20:58
Original
845 people have browsed it

File: deal.php
echo "Your username: $uname";
?> The above program will ask the user to enter a user After submitting the form, user name confirmation information will be returned. It can be seen that uname in the form has become the $uname variable in the deal.php program. Keep it simple. :-)
Let’s take a look at the basic flow control of PHP:
if…else…Elseif
Syntax 1:
if (condition) {
Statement body
}
Syntax Two:
if (condition) {
Statement body one
}else{
Statement body two
}
Grammar three:
if (condition 1) {
Statement body one
}elseif (condition 2) {
Statement body two
}else{
Statement body three
}
We change the above deal.php program to:
if ($uname=="Xiao Ming") {
echo "I'm so happy to see you, Xiao Ming.";
}elseif ($uname=="Xiaohua") {
echo "Oh, it's Xiaohua.";
}else{
echo "You are $uname, right";
}
?>
except if In addition to the statement, there is a while loop, whose syntax is as follows:
while(condition){
Statement body
}
When the condition is true, the statement body is executed. The syntax of
do...while is as follows:
do {
Statement body
}while (condition)
Execute the statement body once first. If the condition is true, the statement body will be executed again in a loop.
The syntax of the for loop is the same as C, as follows:
for (initial condition; judgment condition; condition change) {statement}
And break jumps out of the executing loop, and continue is to interrupt this loop.
Okay, that’s it for this article. I believe you will be able to get started with the above basics very quickly.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/532531.htmlTechArticleFile: deal.php ?php echo "Your username: $uname"; ? The above program will ask The user enters a username and after submitting the form, a username confirmation message is returned. It can be seen that...
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template