以下位代码在“英语”中的含义是什么?
刚开始学习PHP& Codeigniter似乎无法理解它。
<meta name="description" content="<?if (isset($contentdata) && isset($contentdata->description)):?><?=$data->description?><?=$contentdata->description?><?endif;?>" />
据我所知,它从数据库中获取信息,但我不太确定如何,或为什么这两个条件必须为真(&amp;&amp;)。
答案 0 :(得分:1)
//if there's a variable $contentdata AND it has a property ->description
<?if (isset($contentdata) && isset($contentdata->description)):?>
//shorthand syntax for <?php echo $data->description ?>
<?=$data->description?>
//shorthand syntax for <?php echo $contentdata->description ?>
<?=$contentdata->description?>