> function in php ~ Online tutorial

function in php

PHP Functions
The real power of PHP comes from its functions.
In PHP - there are more than 700 built-in functions available.

PHP Functions:
In this tutorial we will show you how to create your own functions.
For a reference and examples of the built-in functions.
Creating PHP functions:
• All functions start with the word "function()"
• Name the function - It should be possible to understand what the function does by its
name. The name can start with a letter or underscore (not a number)
• Add a "{" - The function code starts after the opening curly brace
• Insert the function code
• Add a "}" - The function is finished by a closing curly brace

Use a PHP Function
Now we will use the function in a PHP script:

<html>
<body>
<?php
function writeMyName()
{
echo "Kai Jim Refsnes";
}
echo "Hello world!";
echo "My name is ";
writeMyName();
echo ".That's right, ";
writeMyName();
echo " is my name.";
?>
</body>
</html>


The output of the code above will be:


Hello world!
My name is Kai Jim Refsnes.
That's right, Kai Jim Refsnes is my name.

More about Function
Function with multiple parameter
Function with return value

Please Give Us Your 1 Minute In Sharing This Post!
Please Give Us Your 1 Minute In Sharing This Post!
SOCIALIZE IT →
FOLLOW US →
SHARE IT →
Powered By: BloggerYard.Com

0 comments: