{"id":9348,"date":"2021-01-05T16:01:13","date_gmt":"2021-01-05T21:01:13","guid":{"rendered":"http:\/\/local.brightwhiz\/?p=9348"},"modified":"2021-12-04T06:40:03","modified_gmt":"2021-12-04T06:40:03","slug":"php-ternary-operator-examples","status":"publish","type":"post","link":"http:\/\/local.brightwhiz\/php-ternary-operator-examples\/","title":{"rendered":"How to Use The PHP Ternary Operator With Examples"},"content":{"rendered":"\n

The PHP ternary operator contains three operands and is usually used as a simple alternative to the if \u2026 else<\/strong><\/em> or switch<\/strong><\/em> conditional operators. This operator allows the developer to achieve the same with less code.<\/p>\n\n\n\n

The syntax of the PHP<\/a> ternary operator takes the following format:<\/p>\n\n\n\n

(Condition) ? (Statement1) : (Statement2);<\/code><\/p>\n\n\n\n