close

condition ? value if true : value if false

條件式  ? 當條件式成立時的值 : 當條件式不成立時的值

 

舉例:

$score >59 ? "passed" : "failed"

當分數大於59分時  值等於 passed
        小於59分時  值等於   failed

舊式寫法 

if ($score >59)

"passed";

else

"failed";

arrow
arrow
    全站熱搜

    歐迪設計 發表在 痞客邦 留言(0) 人氣()