SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Zealot DreamDevil's Avatar
    Join Date
    Nov 2000
    Location
    Belgium
    Posts
    102
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Adding value to var

    What is the correct syntax to add a value to a certain variable.

    Ex. $A = $A + $var;

  2. #2
    SitePoint Enthusiast Atrus's Avatar
    Join Date
    Aug 2001
    Posts
    53
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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)

  3. #3
    SitePoint Zealot DreamDevil's Avatar
    Join Date
    Nov 2000
    Location
    Belgium
    Posts
    102
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanx, I'm not used to programming PHP or other languages that have the look of C.

    I'm more active with Pascal/Delphi

  4. #4
    SitePoint Enthusiast Atrus's Avatar
    Join Date
    Aug 2001
    Posts
    53
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •