How to Define a Function in PHP

preview_player
Показать описание
This tutorial will teach you how to define a simple function in PHP and how to define functions with parameters in PHP

In this tutorial you will learn how to define function in php and how to define functions with parameters in PHP. Functions are specially defined set of rules which can be used anywhere in the program. Parameters are the variable we define with the function which will be used inside it.

Step 1: Defining PHP function
In php define function, we simply write the keyword function and then write the name of our function followed by a pair of round brackets.

Step 2: Defining PHP function using 2 parameters

In php define function, the functions can either be without parameters or either can have parameters. Similarly the return value of a function can either be void or can either be a variable. To define a function with parameters, we simply define our function and define the names of the parameters within the round brackets where parameters are separated by commas. The parameters that are defined in a function can only be used within that function as the scope of those variables are limited to this particular function only.

And that's basically it for how to define function in php.
Рекомендации по теме
join shbcf.ru