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

The foreach Statement

The foreach Statement

The foreach statement is used to loop through arrays.

For every loop, the value of the current array element is assigned to $value (and the array pointer is moved by one) – so on the next loop, you’ll be looking at the next element.

foreach (array as value)
{
code to be executed;
}

Example

The following example demonstrates a loop that will print the values of the given array:

<html>
<body>
<?php
$arr=array(”one”, “two”, “three”);
foreach ($arr as $value)
{
echo “Value: ” . $value . “<br />”;
}
?>
</body>
</html>

and output is

Value: one
Value: two
Value: three

The for Statement

The for Statement

For statement is some Looping statements in PHP

The for statement is used when you know how many times you want to execute a statement or a list of statements.

for (initialization; condition; increment)
{
code to be executed;
}

Note: The for statement has three parameters. The first parameter initializes variables, the second parameter holds the condition, and the third parameter contains the increments required to implement the loop. If more than one variable is included in the initialization or the increment parameter, they should be separated by commas. The condition must evaluate to true or false.

Example

<html>
<body>
<?php
for ($i=1; $i<=5; $i++)
{
echo ” The number is $i<br />”;
}
?>
</body>
</html>

And output is

The number is 1
The number is 2
The number is 3
The number is 4
The number is 5

IT Management in the Clouds With SAAS

The way IT is managed today is changing and continues to change rapidly. If once ROI was not considered an issue for the IT manager, today it is the focus. The trend towards SaaS, software as a service, is contributing significantly to the ability of IT managers to cut costs and provide their organizations with a higher level of service.

6 Ways to Speed Up Your Macbook For Free

We all know that installing 4gb of RAM will speed up a Macbook and make the whole experience that little bit more smoother and quicker – but what can you do NOW for FREE that will help speed your bundle of joy along and keep it’s user happier? I will tell you 6 things that will help.