Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Old 01-26-2012, 11:33 PM += and -=
Lashtal's Avatar
wherenomanhasgonebefore

Posts: 680
Name: Lashtal
Trades: 0
Can someone explain the use of these logical operators?
__________________
Currently Reading:
Please login or register to view this content. Registration is FREE
Lashtal is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 01-27-2012, 04:40 AM Re: += and -=
lizciz's Avatar
Super Spam Talker

Posts: 807
Name: Mattias Nordahl
Location: Sweden
Trades: 0
PHP Code:
$a 1;

// this is the same as $a = $a + 3;
$a += 3;

// this is the same as $a = $a - 2;
$a -= 2
__________________
Your answers will only be as good as your question. Formulate it well and give all the necessary information.
lizciz is offline
Reply With Quote
View Public Profile Visit lizciz's homepage!
 
Old 01-27-2012, 05:06 AM Re: += and -=
vectorialpx's Avatar
Extreme Talker

Posts: 249
Name: octavian
Location: Bucharest
Trades: 0
PHP Code:
<?php

// and there is more :)
$m 4;

$m *= 3;
echo 
'<br />$m = '.$m;
// $m = 12

$m /= 2;
echo 
'<br />$m = '.$m;
// $m = 6;

// and more...

$a 2;
$b $a--;
$c + --$a;
echo 
'<br />$a = '.$a;
echo 
'<br />$b = '.$b;
echo 
'<br />$c = '.$c;
/*
will output
$a = 0 ( 2 -1 -1 )
$b = 5
$c = 3

WHY?

* here, $a is still 2
$b = 3 + $a--;

* here $a is 1 (after the -- )
$c = 3 + --$a; // BUT here, it's 0 before the '+' operation

* here $a is 0

*/
?>
__________________
you can
Please login or register to view this content. Registration is FREE

Last edited by vectorialpx; 01-27-2012 at 05:10 AM..
vectorialpx is offline
Reply With Quote
View Public Profile Visit vectorialpx's homepage!
 
Old 01-27-2012, 06:37 AM Re: += and -=
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,384
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
Quote:
Originally Posted by Lashtal View Post
Can someone explain the use of these logical operators?
They are NOT "logical" operators, they are assignment operators
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Reply     « Reply to += and -=
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.46040 seconds with 12 queries