-5

我有这样的代码:

$get_options = isset($options['big_heading']) ? ($options['big_heading']) : '' ;但是我很难将其作为三元运算符来阅读,那么如何将其分解为 if 语句?对不起我的问题...谢谢!

4

6 回答 6

4

您的代码等于:

if(isset( $options['big_heading'])){
    $get_options = $options['big_heading'];
} else {
    $get_options = '';
}

它的语法总是这样的:$foo = (condition) ? if_its_true : if_its_not_true ;

于 2013-07-03T11:59:24.427 回答
1

这与

$get_options = isset( $options['big_heading']) ? ($options['big_heading']) : '' ;

这个

if(isset( $options['big_heading'])) {
    $get_options = $options['big_heading'];
} else {
    $get_options = '';
}
于 2013-07-03T11:59:31.083 回答
1
if(isset( $options['big_heading'])) {
  $get_options = $options['big_heading'];
} else {
  $get_options = '';
}
于 2013-07-03T11:59:33.263 回答
1
$get_options = "";

if(isset( $options['big_heading']))
{
   $get_options = $options['big_heading']
}
于 2013-07-03T11:59:46.147 回答
1
$get_options =  '' ;
if (isset( $options['big_heading'])) {
 $get_options = $options['big_heading'];
}
于 2013-07-03T12:00:09.540 回答
1

干得好...

if (isset($options['big_heading'])){
    $get_options = $options['big_heading'];
else{
    $get_options = '';
}
于 2013-07-03T12:00:12.407 回答