PHP4 Practical Application (9)

Source: Internet
Author: User
"= =" operator
------------------------

As we have mentioned above, PHP4 adds a new = = operator to test whether the variable has the same type. Here's an example:


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

if (! $submit)
{
If $submit does not exist, this implies that the form has not yet been submitted
So the first page is displayed

?>

< html>
< head>
< style type= "Text/css" >
td {Font-family:arial;}
</style>

< body>

< form method= "get" action= "cookie.php" >
< table cellspacing= "5" cellpadding= "5" border= "0>

< tr>
< TD align= "Center" >
Please enter any values or data
</td>
< TD align= "right" >
< input type= "text" name= "Yin" >
</td>
</tr>

< tr>
< TD align= "Center" >
Please enter some more values or data
</td>
< TD align= "right" >
< input type= "text" name= "Yang" >
</td>
</tr>

< tr>
< tr>
< TD colspan= "2" align= "Center" >
< input type= "submit" name= "Submit" value= "test!" >
</td>
</tr>

</table>
</form>
</body>



<?
}
Else
{

If $submit does exist, the form has been submitted
So use the following code to process


if ($yin = = = $yang)
{
$result = "Two variable values and types are identical";
}
Else
{
$result = "Two variable values and types are completely different";
}

?>

< html>
< head>
< Basefont face= "Arial" >

< body>
< b><? echo $result;?></b>

</body>

<?
}
?>
--------------------------------------------------------------------------------


Choose syntax
------------------

PHP also supports a choice syntax for the various control structures currently discussed. For example, you can do this:

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

if ($elvis = = 0)
{
echo "Elvis has left the building!";
}
Else
{
echo "Elvis is still here!";
}

?>

Or you can do this:

<?

if ($elvis = = 0):
echo "Elvis has left the building!";
Else
echo "Elvis is still here!";
endif

?>
--------------------------------------------------------------------------------

The second option is exactly the same as the first, in which a simple colon [:] replaces the first large bracket, removes the second large bracket, and ends with a "endif" statement.

These are the contents of the second part. Next time, we'll bring you loops, arrays and more forms-so be sure not to miss it!



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.