Php operators
$a=2; $b=$a++; what is the value of b? There is a difference between prefix and postfix operator. prefix operator :: first increase(/decrease) 'a', then update 'b'. For $a=2 ; eg.. $b=++$a First increase $a =3 (i.e. a=a+1) Now update $b= 3 (i.e. b=a) Output --> $b= 3 --------------------------------------------------------------- postfix operator :: first update 'b' then increase(/decrease) 'a'. For $a=2 ; eg.. $b=$a++ first update $b =2. (i.e. b=a) Now increase $a= 3. (i.e. a=a+1) Output --> $b= 2
by Mikheili Maglaperidze
2 years ago
PHP
0
Pro tip: use ```triple backticks around text``` to write in code fences