php if else与函数速记

php if else与函数速记,php,conditional-operator,shorthand,Php,Conditional Operator,Shorthand,我怎么能很快写出来 $abc = file_get_contents('one.txt'); if($abc !== '') { msg($abc); } else { msg('nope'); } 我试过: $abc = file_get_contents('one.txt'); if($abc !== '') ? msg($abc) : msg('nope'); 或 而且不工作,请帮忙 在编写三元表达式时,不使用if关键字 ($abc != '') ? msg($abc) : msg('

我怎么能很快写出来

$abc = file_get_contents('one.txt');
if($abc !== '')
{
msg($abc);
} else {
msg('nope');
}
我试过:

$abc = file_get_contents('one.txt');
if($abc !== '') ? msg($abc) : msg('nope');


而且不工作,请帮忙

在编写三元表达式时,不使用
if
关键字

($abc != '') ? msg($abc) : msg('nope');

msg($abc?$abc:'Nope')
($abc != '') ? msg($abc) : msg('nope');
msg($abc != '' ? $abc : 'nope');
<?php
msg(($abc = file_get_contents('blah.txt')) ? $abc : 'Nope');
msg(($abc = @file_get_contents('blah.txt')) ? $abc : 'Nope');