PHP Functions - Full PHP Master

Learn Php & Make Base For Development.

Thursday 15 February 2018

PHP Functions

PHP Functions 
The real power of PHP comes from its functions. 
In PHP, there are more than 700 built-in functions. 
PHP Functions 
In this chapter we will show you how to create your own functions. 
To keep the script from being executed when the page loads, you can put it into a function. 
A function will be executed by a call to the function. 
You may call a function from anywhere within a page. 
Create a PHP Function 
A function will be executed by a call to the function. 
Syntax 
function functionName()
 {
 code to be executed;
 } 
PHP function guidelines: 
  • Give the function a name that reflects what the function does 
  • The function name can start with a letter or underscore (not a number) 
Example 
A simple function that writes my name when it is called: 
Output: 
<html>
 <body> 
 <?php 
  function writeName()
 {
 echo "Kai Jim Refsnes";
 }  
 echo "My name is ";
 writeName();
 ?>  
</body>
 </html>  

My name is Kai Jim Refsnes 

Shape 

No comments:

Post a Comment