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
На этой странице сайта вы можете посмотреть видео онлайн User defined functions in PHP . длительностью часов минут секунд в хорошем качестве, которое загрузил пользователь Student Projects Live 24 Февраль 2017, поделитесь ссылкой с друзьями и знакомыми, на youtube это видео уже посмотрели 217 раз и оно понравилось 1 зрителям. Приятного просмотра!