Home >Backend Development >PHP Tutorial >PHP4 Practical Application Experience Part 3_PHP Tutorial
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!