Quick question about variables

Discussion in 'PHP' started by bartolay13, May 18, 2011.

  1. #1
    someone have use this can please elaborate its behavior.

    $a = "123";
    $p+= $a;

    im little bit confused in using the "+="
     
    bartolay13, May 18, 2011 IP
  2. ademmeda

    ademmeda Active Member

    Messages:
    354
    Likes Received:
    3
    Best Answers:
    3
    Trophy Points:
    70
    #2
    $p += $a;

    is equivalent to

    $p = $p + $a;

    but to use that you need to define $p before.

    $a = 123;
    $p = 25;

    $p += $a;
     
    ademmeda, May 18, 2011 IP
  3. zerokvl

    zerokvl Peon

    Messages:
    19
    Likes Received:
    0
    Best Answers:
    1
    Trophy Points:
    0
    #3
    This type of "behavior" like you said, is used to make the math faster, but like ademmeda said, you must define $p.
     
    zerokvl, May 18, 2011 IP
  4. bartolay13

    bartolay13 Active Member

    Messages:
    735
    Likes Received:
    14
    Best Answers:
    1
    Trophy Points:
    98
    #4
    yes in mathematical operation... hmmm maybe im thinking wrong..
    whats is the procedure used to convert a value to a variable name
    example

    $a = "value";

    then dynamically create new variable name "value"
     
    bartolay13, May 19, 2011 IP