Advertisement
Guest User

functions.php

a guest
Aug 19th, 2019
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.56 KB | None | 0 0
  1. <?php
  2.  
  3. // Define functions
  4. function welcomePerson($person_name, $person_age = 25)
  5. {
  6.     echo "Welcome $person_name, your age is $person_age";
  7.     echo "<br>";
  8. }
  9.  
  10. // Calling functions
  11. welcomePerson("Hani", 27);
  12. welcomePerson("Amin", 24);
  13. welcomePerson("Mohammed");
  14.  
  15. $my_name = 'Ali';
  16. welcomePerson($my_name);
  17.  
  18. function sum($x, $y) {
  19.     return $x + $y;
  20. }
  21.  
  22. echo sum(6, 4);
  23. echo '<br>';
  24. echo sum(3, 4);
  25. echo '<br>';
  26.  
  27.  
  28. // Built-in functions
  29. $arr = ['BMW', 'KIA', 'Audi', 'Mazda'];
  30. echo count($arr);
  31.  
  32. echo '<br>';
  33.  
  34. $str = 'Ahmed';
  35. echo strlen($str);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement