2 responses to “The Ternary Operator in PHP”

  1. Kevin Flavin

    Because I can’t ignore puzzles.

    bar = foo ? bar1 ? foo1 : foo2 :bar2 ? foo3: foo4

    if (foo) then bar = (if (bar1) then foo1 else foo2) else (if (bar 2) then foo3 else foo4)

    bar = foo1 if foo and bar1
    bar = foo2 if foo and not bar1
    bar = foo3 if not foo and bar2
    bar = foo4 if not foo and not bar2

Leave a Reply to admin Click here to cancel reply.