Better way to add number to itself?

后端 未结 9 1400
心在旅途
心在旅途 2020-12-17 14:16

Is there a better/shorter way in PHP of doing

$x = $x + 10;

i.e.

something like

$x .= 10; // (but this doesn\'t add         


        
相关标签:
9条回答
  • 2020-12-17 15:06

    Have a look at: http://php.net/manual/language.operators.assignment.php (in the code examples and comments)

    You can use:

    $x += 10;
    

    for example.

    0 讨论(0)
  • 2020-12-17 15:06

    You are looking for this:

    $x += 10;
    
    0 讨论(0)
  • 2020-12-17 15:08

    Not a PHP guy, but $x += 10; maybe?

    0 讨论(0)
提交回复
热议问题