operators - Reference — What does this symbol mean in PHP? -
what this?
this collection of questions come every , syntax in php. community wiki, invited participate in maintaining list.
why this?
it used hard find questions operators , other syntax tokens.¹
main idea have links existing questions on stack overflow, it's easier reference them, not copy on content php manual.
¹ note: since january 2013, stack overflow does support special characters. surround search terms quotes, e.g. [php] "==" vs "==="
what should here?
if have been pointed here because have asked such question, please find particular syntax below. linked pages php manual along linked questions answer question then. if so, encouraged upvote answer. list not meant substitute others provided.
the list
if particular token not listed below, might find in list of parser tokens.
&
bitwise operators or references
- what mean start php function ampersand?
- understanding php & (ampersand, bitwise and) operator
- php "&" operator
- difference between & , && in php
- what "&" mean here in php?
- what "&" mean in case?
- what "&" sign mean in php?
- what signature mean (&) in php?
- how "&" operator work in php function?
- what & in &2 mean in php?
- when should use bitwise operator?
- is there ever need use ampersand in front of object?
=&
references
- reference assignment operator in php, =&
- what "=&" , "&=" operators in php mean?
- what '&=' , '=&' operators do?
- what =& mean in php?
- 'and' vs '&&' operator
- difference between & , && in php
- is there difference between php operators , and && code?
- php - , / or keywords
- what use of @ symbol in php?
- 'at' symbol before variable name in php: @$_post
- php functions , @functions
- should use @ in php code?
- what ?: in php 5.3?
- what php operators "?" , ":" called , do?
- ?: operator (the 'elvis operator') in php
- where can read conditionals done "?" , ":" (colon)?
- using php 5.3 ?: operator
??
null coalesce operator (since php 7)
:
alternative syntax control structures, ternary operator
- what 2 colons mean in php?
- what's meaning of php token name t_paamayim_nekudotayim?
- what's difference between :: (double colon) , -> (arrow) in php?
- what late static bindings in php?
- static::staticfunctionname()
- unexpected t_paamayim_nekudotayim, expecting t_ns_separator
- what "->" php operator called , how when reading code out loud?
- where use object operator "->" in php?
- what's difference between :: (double colon) , -> (arrow) in php?
- what php syntax $var1->$var2 mean?
- what "->" mean/refer in php?
=>
arrays
- what <<<end mean in php?
- php expression <<<eob
- in php, "<<<" represent?
- using <<<con in php
- what's kind of syntax in php?
- how php equality (== double equals) , identity (=== triple equals) comparison operators differ?
- php != , == operators
- the 3 different equals
- type-juggling , (strict) greater/lesser-than comparisons in php
- what "===" mean?
- how php equality (== double equals) , identity (=== triple equals) comparison operators differ?
- the 3 different equals
- type-juggling , (strict) greater/lesser-than comparisons in php
- php != , == operators
- is there difference between !== , != in php?
- comparing, !== versus !=
- what difference between <> , !=
- php operator <>
- php's <> operator
- what difference between <> , !=
- type-juggling , (strict) greater/lesser-than comparisons in php
<=>
comparison operators (since php 7.0)
- what difference between | , || operators?
- php - , / or keywords
- what || mean?
- the behaviour of or operator in php
+
arithmetic operators, array operators
+=
, -=
assignment operators
++
, --
incrementing/decrementing operators
<?=
short open tags
[]
arrays (since php 5.4)
- php arrays... is/are meaning(s) of empty bracket?
- php : meaning of []
- php array_push() vs myarray[]
- what [] mean when reading php array?
- shorthand arrays: literal
$var = []
empty array
...
argument unpacking (since php 5.6)
**
exponentiation (since php 5.6)
#
one-line shell-style comment
incrementing / decrementing operators
++
increment operator
--
decrement operator
example name effect --------------------------------------------------------------------- ++$a pre-increment increments $a one, returns $a. $a++ post-increment returns $a, increments $a one. --$a pre-decrement decrements $a one, returns $a. $a-- post-decrement returns $a, decrements $a one.
these can go before or after variable.
if put before variable, increment/decrement operation done variable first result returned. if put after variable, variable first returned, increment/decrement operation done.
for example:
$apples = 10; ($i = 0; $i < 10; ++$i) { echo 'i have ' . $apples-- . " apples. ate one.\n"; }
in case above ++$i
used, since faster. $i++
have same results.
pre-increment little bit faster, because increments variable , after 'returns' result. post-increment creates special variable, copies there value of first variable , after first variable used, replaces value second's.
however, must use $apples--
, since first want display current number of apples, , then want subtract 1 it.
you can increment letters in php:
$i = "a"; while ($i < "c") { echo $i++; }
once z
reached aa
next, , on.
note character variables can incremented not decremented , plain ascii characters (a-z , a-z) supported.
stack overflow posts:
Comments
Post a Comment