这行 $_POST 的语法是什么? '':$_POST = ...某事;?
What is the syntax of this line $_POST ? '' : $_POST = ...something;?
我试图通过简化来理解它,但确实有所不同
$apple = 'almwWa';
$banana = 'bababa';
$apple ? '' : $apple = 'dsadsad';
echo $apple;
这是做什么的? ? '' :
原代码是这样的:
$_POST ? '' : $_POST = json_decode(file_get_contents('php://input'), true);
除了第一部分我不明白
这是一个三元运算符(参见http://php.net/manual/en/language.operators.comparison.php)
如果第一部分不为假,则第二部分将为 return 否则第三部分将为 returned。
echo (true) ? "yes" : "no"; //prints yes
echo (false) ? "yes" : "no"; //prints no
我试图通过简化来理解它,但确实有所不同
$apple = 'almwWa';
$banana = 'bababa';
$apple ? '' : $apple = 'dsadsad';
echo $apple;
这是做什么的? ? '' :
原代码是这样的:
$_POST ? '' : $_POST = json_decode(file_get_contents('php://input'), true);
除了第一部分我不明白
这是一个三元运算符(参见http://php.net/manual/en/language.operators.comparison.php)
如果第一部分不为假,则第二部分将为 return 否则第三部分将为 returned。
echo (true) ? "yes" : "no"; //prints yes
echo (false) ? "yes" : "no"; //prints no