PHP Ternary Operator with Example

Published on Mar 22, 2022

The ternary operator is a shorthand for the if...else statement.

Pseudocode

$result = $condition ? $value1 : $value2;
Example

$auth_check = false;

if ($auth_check ) {
	$title = 'Logout';
} else {
	$title = 'Login';
}
PHP