Tuesday, April 14, 2009

Posted by khuyen at 7:06 AM
PHP Functions

previous next



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, please visit our PHP Reference.

Create a PHP Function



A function is a block of code that can be executed whenever we need it.



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



Example



A simple function that writes my name when it is called:










function writeMyName()

{

echo "Kai Jim Refsnes";

}



writeMyName();

?>





0 comments on " "

Post a Comment

 

girl thao can rat nhieu money nen cac ban click vao quang cao cho toi nhe Copyright 2009 Sweet Cupcake Designed by Ipiet Templates Blogger Styles Image by Tadpole's Notez