Ronie_iz_BaD Forums
Would you like to react to this message? Create an account in a few clicks or log in to continue.

Some functions of PHP

Go down

Some functions of PHP Empty Some functions of PHP

Post by rafa1207 Wed Dec 02, 2009 6:57 pm

Hello users of Ronie iz Bad!

I am here to talk about two basic functions of PHP.
The "If" and the "While".

Let's start with the "If":

I'll do a comparison of "if" in our day-to-day.
The "if" can be compared with a chantage. Smile
Example: Do this if not ...

The Sintax of "If":
Code:
if (condition)
  code to be executed if condition is true;
else
  code to be executed if condition is false;

An example:
Code:
$site = "Ronie iz Bad"; // I create a variable "site" with the value is "Ronie iz Bad"
If ($site == "Ronie iz Bad") //  I note that the value of the variable "site" is the value "Ronie iz Bad"
{
echo "You're in the right site!"; // I order prints the text: "You're in the right site!"
}else{
echo "Go to the site Ronie iz Bad!"; // I order prints the text: "Go to the site Ronie iz Bad!"
}
---------------------------------------------------------------------------------
Now go to the "While":

While loop executes a block of code while a condition is true.

The Sintax of "While":
Code:
while (condition)
  {
  code to be executed;
  }

An example:
Code:
$number = 1; // I create a variable "Number" with the value "1"
while ($number <= 10) // Note that the variable "number" is less than or equal to "10"
  {
  echo "The variable 'number' is less than or equal to '10'!"; // I order prints the text: "The variable 'number' is less than or equal to '10'!"
$number++; // Increase the value of the variable "number".
  }

I hope you understand my tutorial!
Any questions post here.

rafa1207

Posts : 2
Points : 5475
Reputation : 2
Join date : 2009-12-02

Back to top Go down

Back to top


 
Permissions in this forum:
You cannot reply to topics in this forum