If you don’t know what ternary operators are then you are missing out! The day I learned about ternary operators I nearly passed out. There are so many wasted lines of code if you don’t know about them. This is what a standard if ... else ... statement looks like using C, Obj-C, C++, C#, Java, or JavaScript:
Colon syntax is another way to style your PHP code. Instead of using curly braces you use colons. Below I have included an example of a couple different curly brace styles and also each statement using the colon syntax. I don’t know of any performance benefits or loss to using this syntax over any other. Please comment here if you have any more information about its affects on performance.
When I started programming I only learned about do ... while statements and I didn’t know about while statements. There are some times when my code would’ve been a lot cleaner if I had known about while statements. To save you all the trouble of what I had to go through I’m writing this post. For those of you who already know the difference between while and do ... while I have included a little-known trick that may interest you. Just skip on down to the bottom.