Re: Operator question
| From: | Jeffrey Labonski | Date: | Tue, 09 Dec 2003 16:48:38 +0000 |
| Subject: | Re: Operator question | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-172277@lists.php.net to get a copy of this message | ||
Uhhh, nope. That only works in your code if $b is initially 0. They're
shorthand for "do something and reassign".
$a = 100;
$a += 10; // $a = $a + 10
$a -= 10; // $a = $a - 10
$a /= 10; // etc...
$a += 10;
$a <<= 2;
$a .= ' is a weird number';
$mode = 0755;
$mode &= 01;
--Jeff
--
Jeffrey Labonski | http://www.eportation.com
Senior Software Developer | (215) 627-2651 voice
ePortation, LLC. | (267) 237-7866 cell
jlabonsk@eportationDOTcom | (215) 893-5287 fax
On Tue, 9 Dec 2003, Richard Davey wrote:
> Hello Jeff,
>
> Tuesday, December 9, 2003, 4:11:10 PM, you wrote:
>
> JM> In PHP, what does the operator "-=" do? I can't find a ref to it's
> JM> function in the online manual or any books I have.
>
> Set's a negative value:
>
> $a = 10;
> $b -= $a;
>
> or
>
> $b -= 10;
>
> In both cases $b will equal -10.
>
>