PHP4 Practical Application Experience (3) _php tutorial

Source: Internet
Author: User
Author: Sun Sports

In PHP, the simplest conditional statement is in the form of an "if" statement, which is generally as follows:
--------------------------------------------------------------------------------
if (condition)
{
Do this!
}
--------------------------------------------------------------------------------
The "condition" here is a description of the condition, and PHP is judged to derive any value of "true" or "false". If it is true, all of the PHP code in the braces will be executed, and conversely, if the code in the braces is false, then the line after the "if" statement structure block will continue to be executed.


We'll show you how the "if" statement works by adding an example of identity authentication to the "login.php" script above. Access is allowed only if the user name entered is "Neo".


--------------------------------------------------------------------------------
< html>
< head>
< Basefont face= "song Body" >

< body>
< center>

<?

Check the name and feedback the appropriate information
if ($name = = "Neo")
{

?>
< font face= "Arial" size= "-1" >
Welcome into the Matrix Neo.
< p>
Maybe it was the force that forced you to do it,,, Oh, improper film! </FONT>

<?
}
?>


<?
If the password is wrong,
if ($name! = "Neo")
{
?>


< font face= "Arial" size= "-1" >
I wonder if you've ever heard of Shakespeare, <? Echo $name;
< p>
He demanded a bouquet of roses for another name, because that bundle might smell more fragrant.
< p>
For you, unfortunately, I disagree. Refuse to enter!
</FONT>

<?
}
?>


</center>
</body>

--------------------------------------------------------------------------------
In this case, the "if" statement feeds back the two information by judging whether the password entered is correct. PHP also allows you to "nest" conditional statements-for example, this is a valid PHP code:

--------------------------------------------------------------------------------
<?

if ($day = = "Thursday")
{
if ($time = = "12")
{
if ($place = = "Italy")
{
$lunch = "pasta";
}
}
}

?>

http://www.bkjia.com/PHPjc/316405.html www.bkjia.com true http://www.bkjia.com/PHPjc/316405.html techarticle Author: Sun Movement in PHP, the simplest form of conditional statements is the IF statement, which is generally as follows:---------------------------------------------------------------------- ----------...

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.