humanware

day_7_functions

Aug 11th, 2018
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.10 KB | None | 0 0
  1. <?php
  2.  
  3. whatIsToday();
  4.  
  5.  
  6. function whatIsToday() {
  7.     echo 'Date ' . date('l');
  8. }
  9.  
  10. echo '<br />';
  11.  
  12.  
  13. function testFunction($test, $test1 = 50) {
  14.     echo $test . ' ' . $test1;
  15. }
  16.  
  17. testFunction('test', 100);
  18.  
  19. echo '<br /><br />';
  20.  
  21. function getSum($num1, $num2) {
  22.     $sum = $num1 + $num2;
  23.     echo 'The sum of num1 and num2 is: ' . $sum;
  24. }
  25.  
  26. getSum(45, 5);
  27.  
  28. echo '<br /><br />';
  29.  
  30. function textStyle($font, $fontSize = 1.5) {
  31.     echo '<h1 style="font-family: ' . $font . '; font-size:'.$fontSize . 'em;">This is Text</h1>';
  32.     // echo '<h1 style="font-family: {$font}; font-size: {$fontSize}em;">This is Text</h1>';
  33. }
  34.  
  35. textStyle('Arial', 3);
  36.  
  37. echo '<br /><br />';
  38.  
  39. function displaySum($num1, $num2) {
  40.     $total = $num1 + $num2;
  41.     return $total;
  42. }
  43.  
  44. echo displaySum(43, 45);
  45.  
  46. echo '<br /><br />';
  47.  
  48. function divideNumbers($dividend, $divisor) {
  49.     $quotent = $dividend / $divisor;
  50.  
  51.     $array = [$dividend, $divisor, $quotent];
  52.  
  53.     return $array;
  54. }
  55.  
  56. list($var1, $var2, $var3) = divideNumbers(20, 5);
  57.  
  58. echo $var1 . ' is divided by ' . $var2 . ' and the quotent is: ' . $var3;
Advertisement
Add Comment
Please, Sign In to add comment