filmov
tv
Else [#17] Code Dynamic Websites with PHP

Показать описание
Lecture 17: Else
We've figured out how to execute some code if an expression evaluates to TRUE, but what about when the expression evaluates to FALSE? Often you'll want to execute some code if a certain condition has not been met.
This is where Else comes in to play. Look at Else as an extension of the If statement. The syntax looks like this:
if (expression) {
// code to execute if TRUE
} else {
// code to execute if FALSE
}
Now, let's take a look at a real-world example:
$fav_fruit = "orange";
if ($fav_fruit == "pineapple") {
echo "YAY! Pineapple is the best.";
} else {
echo "So, you like oranges...";
}
Not all "equals" are created equal
It's good to remember that "==" is different than "=". The former means is equal to while the latter assigns a value to a variable. For example:
if($fav_fruit= "pineapple")
Will always evaluate to true because the single "=" symbol assigns the value into the variable, rather than comparing it.
DOWNLOAD COURSE FILES HERE
We've figured out how to execute some code if an expression evaluates to TRUE, but what about when the expression evaluates to FALSE? Often you'll want to execute some code if a certain condition has not been met.
This is where Else comes in to play. Look at Else as an extension of the If statement. The syntax looks like this:
if (expression) {
// code to execute if TRUE
} else {
// code to execute if FALSE
}
Now, let's take a look at a real-world example:
$fav_fruit = "orange";
if ($fav_fruit == "pineapple") {
echo "YAY! Pineapple is the best.";
} else {
echo "So, you like oranges...";
}
Not all "equals" are created equal
It's good to remember that "==" is different than "=". The former means is equal to while the latter assigns a value to a variable. For example:
if($fav_fruit= "pineapple")
Will always evaluate to true because the single "=" symbol assigns the value into the variable, rather than comparing it.
DOWNLOAD COURSE FILES HERE
Else [#17] Code Dynamic Websites with PHP
Else If [#18] Code Dynamic Websites with PHP
If Statements [#16] Code Dynamic Websites with PHP
Get Your Hands Dirty [#19] Code Dynamic Websites with PHP
Get Your Hands Dirty [#15] Code Dynamic Websites with PHP
String Operators [#23] Code Dynamic Websites with PHP
Logical Operators [#21] Code Dynamic Websites with PHP
Comparison Operators [#20] Code Dynamic Websites with PHP
Form Validation [#42] Code Dynamic Websites with PHP
PHP Syntax [#7] Code Dynamic Websites with PHP
Do While Loop [#28] Code Dynamic Websites with PHP
Foreach Loop [#27] Code Dynamic Websites with PHP
More Variables [#9] Code Dynamic Websites with PHP
Arithmetic Operators [#22] Code Dynamic Websites with PHP
Your First PHP Page [#6] Code Dynamic Websites with PHP
Coding for 1 Month Versus 1 Year #shorts #coding
Associative Arrays [#13] Code Dynamic Websites with PHP
🔥wow this is Amazing | make a website using #chatgpt #viral #coding
This is how long pending takes in roblox #roblox #robux #youtubeshorts #gaming #funny #game
Exposing The 'Expired' Dynamic QR Code Subscription Scam That Inspired Me To Build This We...
If you see this orange dot on your phone, turn it off #shorts
#17 Gatsby Create Pages Programmatically | Dynamic Pages | Create Page Api | Gatsby WordPress Theme
Block List Editor - Building Dynamic Page Layouts in Umbraco V8s
Amazing Rotating Python Graphics Design using Turtle 🐢 #python #pythonshorts #coding #viral #design...
Комментарии