<?php
echo "Using echo:\n";
function add1($x, $y){
$total = $x + $y;
echo $total;
}
$result = add1(2, 2);
echo "2 + 2 = ", $result, "\n";
echo "\n\n";
echo "Using return:\n";
function add2($x, $y){
$total = $x + $y;
return $total;
}
$result = add2(2, 2);
echo "2 + 2 = ", $result, "\n";
?>
PD9waHAKCmVjaG8gIlVzaW5nIGVjaG86XG4iOwoKZnVuY3Rpb24gYWRkMSgkeCwgJHkpewogICAgJHRvdGFsID0gJHggKyAkeTsKICAgIGVjaG8gJHRvdGFsOwp9CgokcmVzdWx0ID0gYWRkMSgyLCAyKTsKCmVjaG8gIjIgKyAyID0gIiwgJHJlc3VsdCwgIlxuIjsKCmVjaG8gIlxuXG4iOwplY2hvICJVc2luZyByZXR1cm46XG4iOwoKZnVuY3Rpb24gYWRkMigkeCwgJHkpewogICAgJHRvdGFsID0gJHggKyAkeTsKICAgIHJldHVybiAkdG90YWw7Cn0KCiRyZXN1bHQgPSBhZGQyKDIsIDIpOwoKZWNobyAiMiArIDIgPSAiLCAkcmVzdWx0LCAiXG4iOwoKPz4=