PHP program to print sum of digits

PHP program to print sum of digits:

The below program gives the sum of two variables x and y. The PHP echo statement is used to output the text and sum value to the screen. In a similar way, codes can be written to get a sum of multiple variables in PHP.


<!DOCTYPE html>
$txt1 = "Sum of x and y is:";
$x = 1234;
$y = 4321;
echo "<h3>" . $txt1 . "</h3>";
echo $x + $y;


Sum of x and y is:
Content Protection by
Please Share