PHP4 practical application experience (3) _ PHP Tutorial

Source: Internet
Author: User
PHP4 practical application experience (3 ). Author: Sun Sports in PHP, the simplest form of condition statement is the if statement, generally as follows: -------------------------------------------------------------------------------- author: Sun Sports

In PHP, the simplest condition statement is an "if" statement, which is generally as follows:
--------------------------------------------------------------------------------
If (condition)
{
Do this!
}
--------------------------------------------------------------------------------
Here, the "condition" is a condition description. after PHP judges, it will produce any value of "true" or "false. If it is a true value, all PHP code in the large arc will be executed. On the contrary, if it is a false value, the code in the large arc will be ignored, continue to execute the rows after the "if" statement structure block.


We will add an authentication example to the above "login. php" script to demonstrate how the "if" statement works. Access is allowed only when the user's user name is "neo.


--------------------------------------------------------------------------------
<Html>
<Head>
<Basefont face = "">
</Head>

<Body>
<Center>

<?

// Check the name and feedback the corresponding information
If ($ name = "neo ")
{

?>
<Font face = "Arial" size = "-1">
Welcome to the parent, Neo.
<P>
You may have been forced to do this by force, oh, an improper film! </Font>

<?
}
?>


<?
// If the password is incorrect
If ($ name! = "Neo ")
{
?>


<Font face = "Arial" size = "-1">
I want to know if you have heard of Shakespeare, <? Echo $ name;?>.
<P>
He asked to get a bunch of roses from another name, because it may smell more fragrant.
<P>
Unfortunately, I don't agree with you. Access Denied!
</Font>

<?
}
?>


</Center>
</Body>

</Html>
--------------------------------------------------------------------------------
In this case, the "if" statement returns two types of information by judging whether the entered password 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 ";
}
}
}

?>

In PHP, the simplest condition statement 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.