Page 1 of 1

a few questions

Posted: Sat Mar 25, 2006 2:13 am
by s.dot
A few things I've been wondering for a while

$foo &= $bar
what's this?

if($a === $b)
if($a !== $b)
why three comparison operators?

$$var
why two $s?

Posted: Sat Mar 25, 2006 2:30 am
by feyd
  1. &= is a bitwise operator. It means L-value = L-value & R-value
  2. === is the identity operator. It's similar to == the equality operator, but also requires the type of the operands to be the same. Same sort of thing for !== being the types must match as well as the values to fail.

    Code: Select all

    '1' == 1; // true
    '1' === 1; // false
    
    '1' != 1; // false
    '1' !== 1; // true
  3. $$var is variable variables. The value in $var is considered the name of a variable thus accessed or set (depending on context)

    Code: Select all

    $foo = 'bar';
    $$foo = 64;
    echo $bar;