What is the correct syntax to add a value to a certain variable.
Ex. $A = $A + $var;
| SitePoint Sponsor |

What is the correct syntax to add a value to a certain variable.
Ex. $A = $A + $var;
Hi!
Your example certainly works! There is a shortcut notation, however:
$A += $var;
This adds the content of $var to that of $A. The result is saved in $A as one might expect.
This also works alike for -= *= .= and possibly many others. It's also widely supported in different programming languages.
Atrus.
Webmaster - Stefan Meier KG TABAKWAREN - Pfeifen, Premium-Zigarren, ... (_Ger)

Thanx, I'm not used to programming PHP or other languages that have the look of C.
I'm more active with Pascal/Delphi
Yeahh, when I was saying 'widely accepted' I was having PHP, Perl, C, Java, JS, etc in mind. I don't remember much Pascal anymore
Regards,
Atrus.
Webmaster - Stefan Meier KG TABAKWAREN - Pfeifen, Premium-Zigarren, ... (_Ger)
Bookmarks