<?php // Faça um Programa que peça dois números e imprima a soma. function sumTwoNumbers($a, $b) { $sum = $a + $b; echo "{$sum}\n"; } sumTwoNumbers(5, 9); // => 14
$age = 38; echo "My name is {$first} {$second} and I am {$age} years old"; ?> </p> <h1>2.Sum two numers</h1> <p> <?php function sumTwoNumbers($first, $second) { $sum = $first + $second; $sumfloat = number_format($sum, 2); echo '$first+$second=' . "{$first}" . "+" . "{$second}" . "=" . "{$sumfloat}" . "<br>"; } sumTwoNumbers(2, 5); sumTwoNumbers(1.2546, 2.1456); sumTwoNumbers(123.456, 555); ?> </p> <h1>3.Dump variable</h1> <p> <?php function printVariable($number) { if (is_numeric($number)) { echo var_dump($number) . "<br>"; } else { echo gettype($number) . "<br>"; } } $number = array("hello", 15, 1.234, array(1, 2, 3)); foreach ($number as $num) {