User defined functions in PHP .

Publicado em: 24 Fevereiro 2017
no canal de: 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


Nesta página do site você pode assistir ao vídeo on-line User defined functions in PHP . duração hora minuto segundo em boa qualidade , que foi baixado pelo usuário Student Projects Live 24 Fevereiro 2017, compartilhe o link com seus amigos e conhecidos, no youtube este vídeo já foi visto 217 vezes e gostou 1 espectadores. Boa visualização!