Thursday, October 25, 2012

Php Tutorials Working with Conditions.

    Working with Php is not as difficult as you might think. One way to think of it would be like making making a list of things to do. And with this list you may want to add more list. Now for a start you have two list. But one list you only want to show to you. And the second list you want everyone else to see. This would be called a Condition. A Conditional statement would be needed to only show your list to you, and only show everyone else the second list. This is what we call a Conditional Statement. Let us look at this example.

IF list one = you;
    {then show list 1} ELSE {show list 2} now this being our Condition.

Now lets see how it works with Php. We now have Objects that we need to assign a Variable to so Php knows what they are. Our Object Variables would be "$list_one" "$list_two" "$you" and "$everyone" . Php makes it simple because you can name your Variables what they represent and Php will store these values temporarily or permanently within the program where you may need them.

$you = 'Bob';
$everyone = 'everyone else !';
$list_one = 'This is your list !';
$list_two = 'This is everyone else's list !';  
IF $you == 'Bob';
    {ECHO "$list_one";} ELSE {ECHO "$list_two";}

Now for each Conditional Check we must have a Operator--
this would be our "= (equals to)"  "==(does equal)" and "!= (does not equal)".
In this case You = Bob so it will show only Your List_one.
You can reverse this also to where your Condition checks if you Does Not Equal or != Then show everyone elses list_two first. 

No comments:

Post a Comment