PHP Ternary Operator with Example

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';
}

Software Engineer | Ethical Hacker & Cybersecurity...

Md Obydullah is a software engineer and full stack developer specialist at Laravel, Django, Vue.js, Node.js, Android, Linux Server, and Ethichal Hacking.