Author: Sun Sports
"= = =" operator
------------------------
As we mentioned above, PHP4 adds a new = = = operator to test if 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 value 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 the $submit does exist, the form has already been submitted.
So use the following code to handle
if ($yin = = = $yang)
{
$result = "Two variables are identical in value and type";
}
Else
{
$result = "Two variable values and types are completely different";
}
?>
< html>
< head>
< Basefont face= "Arial" >
< body>
< b><? echo $result;?></b>
</body>
<?
}
?>
--------------------------------------------------------------------------------
Select 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 one, where you simply replace the first parenthesis with a colon [:], remove the second large bracket, and end with the "endif" statement.
These are the contents of the second part. Next time, we will bring you loops, arrays and more forms-so be sure not to miss it!
http://www.bkjia.com/PHPjc/509180.html www.bkjia.com true http://www.bkjia.com/PHPjc/509180.html techarticle Author: Sun movement "= = =" Operator------------------------as we have mentioned above, PHP4 adds a new = = = operator to test whether the variable has the same type. This ...