the code “ : ” in php

前端 未结 7 853
难免孤独
难免孤独 2020-12-22 13:40

I\'m curious to know what the syntax \" : \" mean in php I\'ve seen it a couple of times but I can\'t seem to explain it to myself. Can you also use it in a sentence....or i

7条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-22 13:53

    This is a short-form conditional expression, known in PHP as the "ternary operator." See the PHP manual for more details on its usage.

    echo ($sheLovesMe ? "She loves me!" : "She loves me not!");
    

提交回复
热议问题