Complete tutorial for Function in PHP

What is Function?

Function are those callable section of code that you can pass data to, and that can return data to you. Function are subprograms which are used to compute a value or perform a task.

PHP Functions Tutorial - Learn PHP Programming - YouTube

Which are the Importance of Function?

  • Easy to debug
  • Reusability
  • No code repetition
  • Easy to handle codes

How to create a Function?

Syntax:-

function function_name( )
{

Block of statement;

}
How to Define, Call & Create a function in PHP? - DevOpsSchool.com

Example:-

Some rules for creating a function:-

  • Function name only starts with a letter, an underscore ( _ ).
  • Function name cannot start with a number.
  • Do not use Predefined constant name e.g. PHP_VERSION ,PHP_OS etc.
  • Do not use reserved keywords. e.g. else, if etc.
  • Function names are case-insensitive, though it is usually good form to call functions as they appear in their declaration.

How Function Calls in code

Ashwani Kumar
Latest posts by Ashwani Kumar (see all)
Tagged : / / / / / / / / / / / / / / /
0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x