PHP Skills Tests: Difference between revisions

From Littledamien Wiki
Jump to navigation Jump to search
(Created page with "Category:PHP == Operator precedence == [http://php.net/manual/en/language.operators.precedence.php PHP's operator precedence]. {| ! Associativity ! Operators ! Additiona...")
 
No edit summary
Line 24: Line 24:
| `++` `--` `~` `(int)` `(float)` `(string)` `(array)` `(object)` `(bool)` `@`
| `++` `--` `~` `(int)` `(float)` `(string)` `(array)` `(object)` `(bool)` `@`
| types and increment/decrement
| types and increment/decrement
|-
| non-associative
| `instanceof`
| types
|-
| right
| `!`
| logical
|-
| left
| `*` `/` `%`
| arithmetic
|-
| left
| `+` `-` `.`
| arithmetic and stirng
|-
| left
| `<<` `>>`
| [http://php.net/manual/en/language.operators.bitwise.php bitwise]
|-
| non-associative
| `<` `<=` `>=` `>`
| comparison
|-
| non-associative
| `==` `!=` `===` `!==` `<>` `<=>`
| comparison
|-
| left
| `&`
| [http://php.net/manual/en/language.operators.bitwise.php bitwise] and references
|-
| left
| `^`
| [http://php.net/manual/en/language.operators.bitwise.php bitwise]
|-
| left
| `<nowiki>|</nowiki>`
| [http://php.net/manual/en/language.operators.bitwise.php bitwise]
|-
| left
| `&&`
| logical
|}
|}



Revision as of 18:13, 15 March 2016

Operator precedence

PHP's operator precedence.

Associativity Operators Additional information
non-associative clone new clone and new
left [ array()
right ** arithmetic
right ++ -- ~ (int) (float) (string) (array) (object) (bool) @ types and increment/decrement
non-associative instanceof types
right ! logical
left * / % arithmetic
left + - . arithmetic and stirng
left << >> bitwise
non-associative < <= >= > comparison
non-associative == != === !== <> <=> comparison
left & bitwise and references
left ^ bitwise
left `| bitwise
left &&` logical

Associativity

TK

Hexidecimal values

echo 0x500;
1280

This is hexidecimal notation. The value is calculated 0 * 1 = 0 + 0 * 16 = 0 + 5 * 256 = 1280.

Bit shifting

TK

is_numeric()

  • Valid values: "200", ".25e4", "20,2"
  • Invalid values: "$200"

Magical constants

Magical constants are constants that change value depending on where in the code they are placed.

The magical constants in PHP are

  • __LINE__
  • __FILE__
  • __DIR__
  • __FUNCTION__
  • __CLASS__
  • __TRAIT__
  • __METHOD__
  • __NAMESPACE__