OkFx.Net, get rebates from your trade

PHP Functions

Create a PHP Function

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

function function_name()
{
code to be executed;
}

Example Use a PHP Function

<html>
<body>
<?php
function writedate()
{
$d = date(”Y-m-d”); //today is 2008-04-27
echo “$d”;
}
echo “Hello world!<br />”;
echo “Today is “;
writedate();
?>
</body>
</html>

and output is

Hello world!
Today is 2008-04-27

Leave a Reply