Introduction to PHP for Drupal Tutorial #5: Nesting If Statements and Switch Statements

preview_player
Показать описание

In this PHP video tutorial, we continue where we left off in #4 and look at nesting IF statements. I show you how we can check for one condition and if it is true, then check for more conditions. From there, we change things up and look at Switch statements. These essentially provide the same functionality as If / Else If statements but can look cleaner and easier to read. Finally, we conclude the tutorial by looking at short form IF statements. This should only really be used for very simple IF evaluations.
Рекомендации по теме
Комментарии
Автор

Hey Johannah, thanks a lot for the feedback! Really appreciate it - it's great to hear the tutorials have helped you out. And with regards to the pace, I'm the exact same way. I find when I watch tutorials that move along slowly, my attention drops and I just start trying to fast forward and stop watching entirely.

yaworsk
Автор

I use to be a asp web developer and learning PHP from your tutorials refreshed all the work i did in my early days. Thanks for creating and posting such nice tutorials for the benefit of all.

vikasarora
Автор

Really appreciate these, coming from a C# / ASP.NET background I find these tutorials super helpful.  Really like the pace, keep up the great work.

andrewgoguen
Автор

You explain logic in a very logical way! Thanks! :)

anne-mariemodery
Автор

nice clear video about PHP if statements. Thank you!

yousofk
Автор

Hey Gary, thanks for the feedback! Glad the fall through example helped. To be honest, with regards to switch (true), i tend to never actually use that... I usually revert back to if statements instead. While I can't say I've gone through a tonne of drupal code, i dont think i've come across a switch(true) use, however, the drupal coding standards don't mention it. Do you have an example of a switch(true) you've used?

yaworsk
Автор

Another good video, really liked your fall through example on switch (something I've only recently got used to). Will you be giving examples of the use of "switch (true)" as I've found the ability to use multiple condition types in switch particularly useful?

garypigott
Автор

Hi, I used it recently in a form validation switch testing multiple field value conditions - rather than using a large if / elseif (tried to post code snippet but you Tube didnt like it). Cheers

garypigott
Автор

Thanks Gary, sounds pretty interesting - if you have a moment, i'd love to see it, you can use my contact form over at my website since YouTube wouldn't allow it

yaworsk
Автор

Hey Pete, good job with the series.  Do you have any tutorials that reference custom hooks and how to create your own module?  If not can you suggest any that do? 

NathanMelen
welcome to shbcf.ru