PHP、Shorthand、If..Else 使用三元运算符

PHP, Shorthand, If..Else using Ternary Operators

有专门的班轮吗?一个不错的三元 OP?

$F_NAME = $_SESSION['USR']['F_NAME'];
if(isset($_POST['F_NAME'])) {$F_NAME = $_POST['F_NAME'];}

基本上"If the POST is sent, show that, even if the post is empty, otherwise grab the value from the session, but only if the post was not set or empty"

这里真的是吹毛求疵...

寻找这样的东西:

$F_NAME = ? ($F_NAME ? isset($_POST['F_NAME']) : $_SESSION['USR']['F_NAME']);

应该是:

(conditions) ? true : false
   satisfies <--^      ^----> did not satisfy

所以这等同于:

$F_NAME = isset($_POST['F_NAME']) ? $_POST['F_NAME'] : $_SESSION['USR']['F_NAME'];

作为Ghost响应,甚至更短

$F_NAME = $_POST['F_NAME'] ? : $_SESSION['USR']['F_NAME'];