PHP – return statement

The return statement in PHP is used to stop the program execution and returns the program control in the beginning of the program.

The return statement in PHP can be used in several ways:

  1. if return statement is called in a function, then it will stop the program execution immediately and return its argument as a value of the program.
  2. The return statement can also ends the execution of any eval() statement or script file.
  3. If in case, the current script file is included or required, then control will be passed back to the calling file.
  4. And if no parameter is passed in the return statement then it will return a NULL value.

Example1 for return statement in PHP

Example2 for return statement in PHP

Example3 for return statement in PHP

 

Leave a Reply

Your email address will not be published.