I'm learning ternary expressions in PHP and was wondering if someone could verify that the following two blocks of code are the same as far as what is the outcome?
$caption = $_POST['caption'] == '' ? NULL : $_POST['caption'];
Is the above the same as the below?
if ( $_POST['caption'] == '' ) {
$caption = NULL;
}
else {
$caption = $_POST['caption'];
}