User defined functions in PHP .

Published: 24 February 2017
on channel: Student Projects Live
217
1

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


On this page of the site you can watch the video online User defined functions in PHP . with a duration of hours minute second in good quality, which was uploaded by the user Student Projects Live 24 February 2017, share the link with friends and acquaintances, this video has already been watched 217 times on youtube and it was liked by 1 viewers. Enjoy your viewing!