if statement

No swearing, link posting, adult oriented, or illegal posts.
Post Reply
Site Admin
Posts: 175
Joined: Sat Jan 11, 2020 12:44 am

if statement

Post by Chris »

When building your code, there will be lot of information that you will need to compare. One of the ways to compare is using an If statement.

When you use the If statement, you are comparing two items to see if they are the same or different information.

if ($a1 == "Yes")
echo "the items compared are the same";

As you can see, the code is checking to see if the $a1 holds the information Yes.
If it does, then it will print out "the items compared are the same".
If it does not equal, then it will not print out "the items compared are the same".

A simple code that can use this is:


if ($ChosenName == "Mac") echo "Hello Mac!<br /><br />";
if ($ChosenName == "John") echo "Hello John!<br /><br />";

echo "Please state your name: ";
echo "<a href="thiscode.php?name=John>John</a><br />";
echo "<a href="thiscode.php?name=Mac>Mac</a><br >";

As you can see, Clicking on John (Which the line will only show John) will give you the response as "Hello John!" with two returns. That section will only give you one of the choices to be shown.
Support these areas by allowing Advertisements! :geek:
Post Reply