note 34075 added to language.operators
| From: | abodeman at rack1 dot php dot net | Date: | Tue, 15 Jul 2003 16:15:11 +0000 |
| Subject: | note 34075 added to language.operators | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-52142@lists.php.net to get a copy of this message | ||
Two operators that don't seem to be in the manual anywhere are the unary plus and the unary
minus. The unary minus returns the opposite of its argument, and the unary plus appears to do
nothing. These operators are apparently on the same level of precedence as !, ~, ++, --, the casts,
and @. The following example may provide a better explanation than this paragraph did:
$zero = 0;
$three = 3;
$four = 4;
$neg_three = -3;
$neg_four = -4;
$a = -$three; // $a is -3
$b = -$neg_three; // $b is 3
$c = -$zero; // $c is 0
$d = +$three; // $d is 3
$e = +$neg_three; // $e is -3
$f = +$zero; // $f is 0
$g = -!$zero; // $g is -1
$h = !-$zero; // $h is 1
$i = -$d++; // $i is -3, $d is 4
----
Manual Page -- http://www.php.net/manual/en/language.operators.php
Edit Note -- http://master.php.net/manage/user-notes.php?action=edit+34075
Delete Note -- http://master.php.net/manage/user-notes.php?action=delete+34075&report=yes
Reject Note -- http://master.php.net/manage/user-notes.php?action=reject+34075&report=yes