Contact Us

Language Equivalents >> Operators Compared

Index

Operators Compared

  C# PHP4 PHP5 ActionScript JavaScript Ruby
Additive      
Addition + + + + + +
Subtraction - - - - - -
Multiplicative      
Multiplication * * * * * *
Division / / / / / /
Integer division /     /   /
  Modulus division (returning only the remainder) % % % % % %
  Exponentiation n/a n/a n/a n/a n/a **
Assignment            
  Assignment = = = = = =
  Addition += += += += += +=
  Subtraction -= -= -= -= -= -=
  Multiplication *= *= *= *= *= *=
  Division /= /= / = /= /= /=
  Integer division /= n/a n/a /=   /=
  Exponentiation n/a n/a n/a n/a n/a  
  String concatenation += .= .= += += +=
  Modulus division %= %= %= %= %= %=
  Left shift <<= <<= <<= <<= <<= <<
  Right shift >>= >>= >>= >>= >>= >>
  Bitwise AND &= & & &= &= &=
  Bitwise exclusive OR ^= ^= ^= ^= ^= ^=
  Bitwise inclusive OR |= |= |= |= |= |=
  Null coalescing ?? n/a n/a n/a n/a n/a
Relational and equality            
  Less than < < < < < <
  Less than or equal to <= <= <= <= <= <=
  Greater than > > > > > >
  Greater than or equal to >= >= >= >= >= >=
  Equal == == = = == == ==
  Not equal != <> != <> != != != !=
  Reference variable comparison == == == == == ==
  Reference type comparison x is Class1 (also see as and typeof) is_a() is_a()$a instanceof MyClass typeof(str) === ''// 'Object','String','Number','Undefined','Boolean' === instance_of? is_a? kind_of?
  String comparison == Equals == == == == ==
  CString concatenation + . . + + +
  Short circuited Boolean AND && && && && && &&
  Short circuited Boolean OR || || || || || ||
Bit shift            
  Left shift << << << << << <<
  Right shift >> >> >>  >> >> >>
Scope resolution            
  Scope resolution . base ::parentself :: parentself .super n/a ::
Postfix            
  Array element [ ] [ ] [ ] [ ] [ ] [ ]
  Function call ( ) ( ) ( ) ( ) ( ) ( )
  Type cast or conversion (type) (type) (type) type(varName) Automatic datatype conversions  
  Member selection . ->(instance):: (constant, status) ->( instance):: (static constant , status) . .
obj["properyName"]
.
  Postfix increment ++ ++ ++ ++ ++ n/a
  Postfix decrement -- -- -- -- -- n/a
Unary            
  Indirection * (unsafe mode only) n/a n/a * n/a  
  Address of & (unsafe mode only; also see fixed) n/a n/a n/a n/a  
  Logical NOT ! ! ! ! !  
  One's complement ~ n/a n/a n/a    
  Prefix increment ++ ++ ++ ++ ++  
  Prefix decrement -- -- -- -- --  
  Size of type sizeof n/a n/a n/a n/a  
  Comma n/a n/a n/a   ,  
Bitwise            
  Bitwise AND & & & & & &
  Bitwise exclusive OR ^ ^ ^ ^ ^ ^
  Bitwise inclusive OR | | | | | |
Logical            
  Logical AND & and&& and&& & & &
  Logical OR | or || or || | || |
Conditional            
  Ternary conditional ?: ?: ?: ?: ?: ?:
Pointer to member            
  Pointer to member . (Unsafe mode only) :: ::   . or
obj["propertyName"]
.
Reference            
  Reference n/a (use reference types) & &   n/a  
  C# PHP4 PHP5 ActionScript JavaScript Ruby
渝ICP备08003290号