Home > Backend Development > PHP Tutorial > PHP4 Practical Application Experience (4)_PHP Tutorial

PHP4 Practical Application Experience (4)_PHP Tutorial

WBOY
Release: 2016-07-21 16:02:51
Original
824 people have browsed it

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>

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/316398.htmlTechArticleAuthor: Sun Movement In addition to the if statement, PHP also provides an if-else structure to define when in the statement The PHP code executed when the condition description is "false" value. The if-else structure is used as follows:...
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