Author: Sun sports
"=" Operator
------------------------
As mentioned above, a new = Operator is added to PHP4 to test whether the variable has the same type. Here is an example:
--------------------------------------------------------------------------------
<?
If (! $ Submit)
{
// If $ submit does not exist, it indicates that the form has not been submitted.
// Display the first page
?>
<Html>
<Head>
<Style type = "text/css">
Td {font-family: Arial ;}
</Style>
</Head>
<Body>
<Form method = "GET" action = "cookie. php">
<Table cellspacing = "5" cellpadding = "5" border = "0>
<Tr>
<Td align = "center">
Enter any numeric value or data
</Td>
<Td align = "right">
<Input type = "text" name = "yin">
</Td>
</Tr>
<Tr>
<Td align = "center">
Enter another value 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>
</Html>
<?
}
Else
{
// If $ submit does exist, the form has been submitted.
// Use the following code for processing
If ($ yin ===$ yang)
{
$ Result = "the values and types of the two variables are identical ";
}
Else
{
$ Result = "two variable values and types are completely different ";
}
?>
<Html>
<Head>
<Basefont face = "Arial">
</Head>
<Body>
<B> <? Echo $ result;?> </B>
</Body>
</Html>
<?
}
?>
--------------------------------------------------------------------------------
Select syntax
------------------
PHP also supports a selection 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 the following:
<?
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. In this structure, replace the first large arc with a colon [:], remove the Second Large arc, and end with an "endif" statement.
These are the content of the second part. Next time, we will bring you loops, arrays and more forms-so do not miss it!