The if/else statement
Has any ever said to you “if you work hard, then you will succeed in whatever you do”? And then what happens when you don’t work hard?, Well, you will fail it’s as simple as that. This is an example of an if/else statement.
- If you work hard then you shall achieve whatever it was that you had set out to do.
- Else, if you don’t work hard, then you will fail and shall not be rewarded for your lack of effort.
How does this translate into something that is useful for the
php developers? Well think about this for instance:
Someone comes to your website and you want to ask this particular visitor if this is their first trip to your website. With an if statement this is easy enough to do. Simply have a statement to check off, “are you visiting this webpage for the first time.” If the condition statement is true then have them directed to the “insert your name” page, else let them view the website as they normally would because you have already asked them for their name in the past.
(
Read more
)