if-instruction
With "if" you can check if something has been done (has a certain condition been fulfilled?).
An if-instruction could look like this:
<?php
if(condition)
{
instruction
}
?>
The condition that ought to be checked is set in brackets after the initial "if". The instruction is following in curly brackets. It is executed if the condition is true.
An example:
<?php
$name = "Franz";
if($name == "Franz")
{
echo "Hello Franz";
}
?>
"if" checks, if the variable "$name" has the content "Franz". If that's the case "if" returns true and we get the output Hello Franz.
Please note that you have to use two equals signs ("==").
If the variable "$name" doesn't have the content Franz, "if" returns false and you get no output.
To get an output after a false condition we need the else-instruction.
It looks like this:
<?php
if(condition)
{
instruction
}
else
{
instruction
}
?>
"else" always occurs, when a false is returned during a check.
An example:
<?php
$name = "Franz";
if($name == "Franz")
{
echo "Hello Franz";
}
else
{
echo "You aren't Franz";
}
?>
If the variable "$name" isn't Franz, you will get the output "You aren't Franz" in the web WWW- und FTP-Servern im Internet abzurufen. Bekannte Browser sind Netscape Navigator, Microsoft Internet Explorer, Opera und Mosaic.">browser.