| | |||||
| ||||||||
| Webmaster Tutorials Instructional webmaster-related how-to's and tutorials. |
![]() |
| | LinkBack | Thread Tools |
| | THREAD STARTER #1 (permalink) | ||||
| Senior Member Join Date: Dec 2006 Location: England
Posts: 1,565
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() | PHP: Ternary Operators Note this tutorial was written a while back, as such my coding habits have been changed a bit and some formatting it a bit out of date ![]() This tutorial will explain the method known as "ternary operators" which you will see me especially using a lot. They are also present in javascript and a few other languages, but that's not the point of this tutorial. It's just a quicky and not that in depth but i hope you get something out of it. Every found your self diving into endless reams of code just to set a simple variable?? e.g: PHP Code: The Quick if! It works like this:
PHP Code: Of course you can also do: ????: NamePros.com http://www.namepros.com/showthread.php?t=281181 PHP Code: PHP Code: Anything really, its a good way of keeping order in your code and sparing your fingers. There are a few disadvantages to this technique, for starters it is rarely ever used within a tutorial as the conditional can be missed and since the technique is not widely used it is also not widely understood. The format of the conditional is also not great when debugging. Any questions/comments, post below and when i get time i or someone else will reply. Matt. | ||||
| |
| | #2 (permalink) |
| NamePros Regular Join Date: Mar 2006 Location: United Kingdom
Posts: 413
![]() ![]() ![]() | Thanks for explaning that, I'd seen similar syntax a while back and didn't exactly understand how it worked Rep++ (I think)
__________________ Linux Screenshots |
| |