PHP Shorthand Conditional

When validating user input you commonly use isset to check the existence of some data. Then, you usually use the result of that condition to set the value of another variable. Writing these checks repeatedly quickly becomes annoying.

Ternary

<?php
$action = (empty($_POST['action'])) ? 'default' : $_POST['action'];

Null Coalescing Operator

<?php
$action = $_POST['action'] ?? 'default';

Learn more about PHP comparison operators.

PHP 8 introduces a similar feature called the nullsafe operator. This also reduces the amount of repetition in your code.