PHP4 Practical Application Experience Part 3_PHP Tutorial

WBOY
Release: 2016-07-13 17:28:20
Original
793 people have browsed it

Author: Sun Movement
In PHP, the simplest form of conditional statement is the "if" statement, which generally looks like the following:
------------------ -------------------------------------------------- ------------
if (condition)
{
do this!
}
-------------- -------------------------------------------------- ----------------
The "condition" here is a description of a condition, and PHP will get any value of "true" or "false" after judgment. If it is true, all the PHP code in the curly brackets will be executed. On the contrary, if it is false, the code in the curly brackets will be ignored and execution will continue with the lines after the "if" statement structure block.
We will show you how the "if" statement works by adding an authentication example to the "login.php" script above. Access is only allowed if the username entered by the user is "neo".
----------------------------------------------- ----------------------------------






// Check the name and feedback the corresponding information
if ($name == "neo")
{
?>

Welcome to the matrix, Neo.

Maybe you were forced to do this by force,,,oh, illicit video!


}
?>
//If the password is wrong
if ($name != "neo")
{
?>

I wonder if you've heard of Shakespeare, .

He asked for a bouquet of roses with another name ize because that bunch might smell a little more aromatic.

Unfortunately for you, I disagree. Entry refused!

}
?>



--------- -------------------------------------------------- --------------------------
In this case, the "if" statement feeds back the corresponding two pieces of information by judging whether the entered password is correct. PHP also allows you to "nest" conditional statements - for example, this is a valid piece of PHP code:
-------------------------- -------------------------------------------------- ----
if ($day == "Thursday")
{
if ($time == "12")
{
if ($place == "Italy")
{
$lunch = "pasta";
}
}
}
?>

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/531788.htmlTechArticleAuthor: Sun Sports In PHP, the simplest form of conditional statement is the if statement, which generally looks like the following: -------------------------------------------------- ----------------------------------...
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