Page 93 - Open Soource Technologies 304.indd
P. 93
Open Source Technologies
Notes The result of this example is
Jonathan
When returning a variable by-reference from a function (covered later in this book), you also
need to use the assign by-reference operator to assign the returned variable to a variable:
$retval =& func_that_returns_by_reference();
6.1.3.3 Comparison Operators
Comparison operators enable you to determine the relationship between two operands. When
both operands are strings, the comparison is performed lexicographically.
The comparison results in a Boolean value. For the following comparison operators, automatic
type conversions are performed, if necessary
Operator Name Value
== Equal to Checks for equality between
two arguments performing
type conversion when
necessary: 1 == “1” results
in true 1 == 1 results in true
!= Not equal to Inverse of ==.
> Greater than Checks if first operand is
greater than second
< Smaller than Checks if first operand is
smaller than second
>= Greater than or equal to Checks if first operand is
greater or equal to second
<= Smaller than or equal to Checks if first operand is
smaller or equal to second
For the following two operators, automatic type conversions are not performed and, therefore,
both the types and the values are compared.
Operator Name Value
=== Identical to Same as == but the types
of the operands have
tomatch. No automatic type
conversions are performed:1
=== “1” results in false.1 ===
1 results in true.
!== Not identical to The inverse of ===.
6.1.3.4 Logical Operators
Logical operators first convert their operands to boolean values and then perform the respective
comparison.
88 LOVELY PROFESSIONAL UNIVERSITY