1. Home
  2. Php
  3. Ternary operator
#php#conditional

Ternary operator evaluates first parameter followed by two values. First value is returned when the condition is true otherwise the second value is returned.

// Condition ? True : False

$hour = 14;
($hour <= 12) ? "Morning" : "Afternoon";
copy
Full Php cheatsheet
Sitemap Git repository