Advertisement
karlakmkj

php function

Sep 14th, 2021
1,233
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.57 KB | None | 0 0
  1. <?php  
  2. /*
  3. can leave out ?> to execute and print at terminal.
  4. */
  5.  
  6. function countdown()
  7. {
  8.   echo "4, 3, 2, 1, ";
  9.   return "blastoff!"; //return should always be the last line in the function
  10. }
  11.  
  12. $return_value = countdown(); //assign function to a variable, which also invokes the function to print echo line
  13. echo $return_value;  //then this prints the return stm
  14.  
  15. // Empty function that returns NULL
  16.   function createVacuum(){
  17.     return NULL; //can also leave this line out, especially the return keyword
  18.   }  
  19.  
  20. echo createVacuum() * 10; // value printed as 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement