Course Title: Web Development Masterclass
Course Link: http://youaccel.com/admin/cdisplay.ph...
Facebook: / youaccel
Twitter: / youaccel
Website: http://youaccel.com
Tutorial Content:
In this lesson we will be exploring conditional statements. When writing code, we often want an action to occur, based on an event or condition.
In PHP we have different types of conditional statements, including:
if statements
if-else stements
if-else-elseif statements
switch statements
We will start with an example of a basic if statement.
Here, we have a variable x, set to a value of 49.
We have created an if statement with one condition. If the value of x is less than 50 - we want to output the words "Condition Met".
Since 49 is less than 50, we can see in our web browser that the words were outputted.
Now, what would happen if the condition was not met. Let's say we set x to 51. In this case 51 is not less than 50 - so there is no output in our web browser.
There is no output because we have not instructed our script on how to handle this condition.
To do so, we can add an else statement.
Let's create an else statement that outputs the words "Condition Not Met" if x is not less than 50.
So let's recap what we have done here.
As seen in our web browser the correct line is outputted.
You can change the value of x to test different results.
On this page of the site you can watch the video online PHP Conditional Statements | Tutorial with a duration of hours minute second in good quality, which was uploaded by the user YouAccel 09 May 2019, share the link with friends and acquaintances, this video has already been watched times on youtube and it was liked by 0 viewers. Enjoy your viewing!