To add two numbers in PHP, you can simply use the plus sign (+) operator.
main.php90 chars6 linesThis will output:
main.php27 chars2 lines
In the code above, we have defined two variables $num1 and $num2 and assigned them the values 5 and 10 respectively. We then used the plus sign (+) operator to add them together and stored the result in $sum. Finally, we used echo to display the result on the screen.
gistlibby LogSnag