Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Plus +

+ is a native PHP operator. It has three usages:

  • The addition, as in mathematics, on numbers. This works on integers and floats.
  • The merging of arrays. This merge sets the keys once, then omits the next values. This is distinct from array_merge().
  • The + sign in front of a number, to make it explicitly positive. This is optional, and may be repeated.
<?php

    $a = 1 + 2; // 3
    
    $b = [1, 2] + [3, 4, 5]; // [1,2, 5]
    
    $c = +6; // 6 

?>

Documentation

See Also