PHP Switch Statement - Switch vs if/else statement - Full PHP 8 Tutorial

preview_player
Показать описание
In this PHP tutorial you will learn about the switch statement in PHP, how to use it with examples, concerns when using switch statement within loops & the differences between the series of if statements & the switch statement. The switch statement is similar to if, elseif, else statements. The main difference is that the switch statement takes a single expression & compares its value against multiple values (cases).

SOME OF THE WAYS YOU CAN SUPPORT THE CHANNEL
👍 Smash the like button
🤝 Subscribe to the channel & turn the notifications on
💬 Post comments on videos, any feedback is greatly appreciated
THANK YOU!

LESSON 1.17

RESOURCES

CHAPTERS
00:00 - Switch statement
00:50 - Default case
01:00 - Break statement within switch & how does switch statement work
02:39 - Fall-through strategy & use-case of omitting the break statement
03:28 - Loose comparison
04:10 - Switch statement within loops & using break
04:57 - Using continue statement within the switch statement that's within loop
05:42 - Difference between switch statement & series of if statements (switch vs if). Demonstrating example of the performance difference
Рекомендации по теме
Комментарии
Автор

Gio, I've said it before but I MUST reiterate it. Your tuts are THE VERY BEST on YT. You are so knowledgeable and you explain everything so thoroughly. I never thought I'd actually love watching a YT tut. But I love yours. And can't wait for the upcoming Laravel tuts. Keep up the great work!

mnamhie
Автор

Your tutorials are really awesome, not just for sake of videos, they are perfectly made with relevant information, great work

smartsavage
Автор

it's never too soon to discuss how to ensure your code is running as efficiently as possible. These computationally expensive examples really make the point clear.
Thank you for always having efficiency top of mind while you teach these concepts.

lotuslando
Автор

last part explaining switch vs multiple if elseif great insight

mukundbhatia
Автор

Another perfect video, I just love how you explain and then show it with examples that is one of the best parts of your videos.Thanks!

Armando-pxhi
Автор

This series points me out that how less I know about PHP 😢

The avoiding code duplication tip on switch statement is literally a new thing to me! Glad to have the series ☄️

alnahian
Автор

Very thorough explanation of the difference between if/else and switch. Nice.

jeffsnow
Автор

The witch statement is fabulous. Thanks for the video again!

zhozfem
Автор

Like how you referred to breaking out of the array, very helpful. Thanks for posting

Timespider
Автор

Your lessons are definitely helping me with my php skills. I wish more people would find you. I'll share to as many people as i can.

michaeljean
Автор

Very clear, very precise tutorial, thanks!

photoinshot
Автор

Awesome your tutorials are the best, thanks a lot

hav_bslll
Автор

thank you thank you thank you thank you thank you thank you , great work excellent,

mortezashabanipour
Автор

I know the real reason why we should use 'break' after watching this video. Thanks

jessieren
Автор

The only time an if statement is faster than switch is if the if is with ===. Thank you for the video

marwanak
Автор

Can you put the list number of each video to their titles? Like: 1.16 Loops

keremardicli
Автор

Hi Gio, Does continue; works as break; only in switch to avoid infinity.
Thanks

open-mindedlearners
Автор

Meaning switch statements run faster than if statements ?>

nelsonke