Welcome to PHP programming,
In PHP, a function is a block of code that can be executed whenever we need it.
Creating a PHP function
1) All functions start with a word "function".
2) Name the function - It should be possible to understand what function does by its name.
The name can start with a letter or underscore.
3) Add a "{" - The function code starts after the opening curly brace.
4) Insert the function code.
5) Add a "}" - The function is finished by a closing curly brace.
Syntax:
function function_name(parameters)
{
code to be executed;
}
Calling a function
After the function is created, it must be called to be executed using the function_name.
Syntax:
function_name(parameters);
or
$varname=function_name(parameters);
Let us write a simple PHP code using functions with one parameter
Save it in our server ie, xampp/htdocs
Run the code using the url http://localhost/phpfunction1.php
Let us write a simple PHP code using function with two parameters
save it in our server i.e., xampp/htdocs
run the code using the url http://localhost/phpfunction2.php
PHP Function - Return Values
Function can also be used to return values.
Let us write a #PHP code using function to return values
Save it in our server i.e, xampp/htdocs
run the code using the url http://localhost/phpreturn.php
This is how functions work with PHP #script.
Thank You.......
For source code kindly refer www.studentprojects.live
Do you have Any queries? Contact us in Whatsapp :- +91-9972853368
#studentprojects #phpcode
En esta página del sitio puede ver el video en línea User defined functions in PHP . de Duración hora minuto segunda en buena calidad , que subió el usuario Student Projects Live 24 febrero 2017, comparta el enlace con amigos y conocidos, en youtube este video ya ha sido visto 217 veces y le gustó 1 a los espectadores. Disfruta viendo!