Friday 19 April 2013

PHP Function


This is one of the flagship to PHP, PHP has about 700 function.

PHP Function.
Where we will learn how to make PHP function.

To keep the gnats in the script is not run when the page is loading then our website will give the event to run a function that we have made, or function we have created will be run at certain moments that we have set.

You can run a function or a function call from anywhere.

Creating Function.
Function will be run based on an event that has been set

syntax:
<? php
namaFunction function () {
Code / syntax to be on the run;
}
?>

Function name can start a letter or underscore and must not use numbers.

EXAMPLE:
<? php
function name () {
echo 'Budi';
}
echo 'my name'
name ();
?>
RESULTS:
My name is Budi

PHP Function With Parameters.
To create a function that we create more power full we can add a parameter to the function that we have made, the meter is usually a variable.
And put after the name of the parameter in the function

EXAMPLE:
<? PHP
function name ($ x) {
echo 'My name'. $ x. '<br />';
}
?>
name ('Budi');
name ('Andy');

RESULTS:
My name is Budi
My name is Andi

No comments:

Post a Comment