Month: March 2015

  • The Problem of Ternary Operators in PHP

    How do you think of the ternary operators in PHP? Recently, I’’ve used the code written as below: echo (1?”Y”:0?”N”:””); The code returns “N” but not “Y”. How does it work? It shoud be like: echo ((1?”Y”:0)?”N”:””); Finally, please follow the advice from PHP docs: It is recommended that you avoid “stacking” ternary expressions. PHP’s…