PHP Conditional Statements | Tutorial

Veröffentlicht am: 09 Mai 2019
auf dem Kanal: YouAccel
0

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.


Auf dieser Seite können Sie das Online-Video PHP Conditional Statements | Tutorial mit der Dauer stunde minuten sekunde in guter Qualität ansehen, das der Benutzer YouAccel 09 Mai 2019 hochgeladen hat, den Link mit Freunden und Bekannten teilen, dieses Video wurde auf Youtube bereits Mal angesehen und es wurde von 0 den Zuschauern gefallen. Viel Spaß beim Betrachtenden Zuschauern gefallen!