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 that this structure can be used to greatly simplify the example in the previous article - Instead of two separate "if" statements nested, we can mix them in a single "if-else" statement:
-------------- -------------------------------------------------- ----------------
< html>
< head>
< basefont face="Arial">
< ; /head>
< body>
< center>
< ?
// Check the name and feed back the corresponding information
if ( $name == "neo")
{
?>
< font face="Arial" size="-1">
Welcome to the matrix, Neo.
< p>
Maybe you were forced to do this by force,,,oh, illicit video!
< /font>
< ?
}
else
{
?>
< font face=" Arial" size="-1">
I wonder if you've ever heard of Shakespeare, < ? echo $name; ?>.
< p>
He asked for a bunch of other A roseification of a name because that bunch might smell a little more fragrant.
< p>
Unfortunately for you, I disagree. Entry refused!
< /font>
< ?
}
?>
< /center>
< /body>
< /html>