PHP Conditional Statements | Tutorial

Publicado em: 09 Maio 2019
no canal de: 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.


Nesta página do site você pode assistir ao vídeo on-line PHP Conditional Statements | Tutorial duração hora minuto segundo em boa qualidade , que foi baixado pelo usuário YouAccel 09 Maio 2019, compartilhe o link com seus amigos e conhecidos, no youtube este vídeo já foi visto vezes e gostou 0 espectadores. Boa visualização!