Author: Sun Movement
In addition to the "if" statement, PHP also provides the "if-else" structure, which is used to define the PHP code that is executed when the condition in the statement is described as a "false" value.
The "if-else" structure is used as follows:
----------------------------------------- ------------------------------------------
if (condition)
{
do this!
}
else
{
do this!
}
---------------------------------- -----------------------------------------------
You will see As you can see, this structure can be used to greatly simplify the example from the previous article - instead of two separate "if" statements nested, we can mix them into a single "if-else" statement:
-- -------------------------------------------------- ----------------------------
< html>
< head>
< basefont face="Arial">
< /head>
< body>
< center>
< ?
// Check the name and feedback the corresponding information
if ($name == "neo")
{
?>
< font face="Arial" size="-1">
Welcome to the mother body, Neo.
< p>
Maybe you were forced to do this by force,,,oh, illicit video!
< /font>
< ?
}
else
{
?>
< font face="Arial" size="-1">
I was wondering if you've heard of Shakespeare, < ? echo $name; ?>.
< p>
He asked for a bouquet of roses with another name because that bouquet might smell more fragrant.
< p>
Unfortunately for you, I disagree. Entry refused!
< /font>
< ?
}
?>
< /center>
< /body>
< /html>
The above has introduced the practical application experience of PHP4 Part 4, including various aspects. I hope it will be helpful to friends who are interested in PHP tutorials.