当前位置: 代码迷 >> PHP >> 请问一段wordpress 语句的意思
  详细解决方案

请问一段wordpress 语句的意思

热度:11   发布时间:2016-04-28 16:49:35.0
请教一段wordpress 语句的意思
$templates = array();

if ( '' !== $name )
$templates[] = "header-{$name}.php";

$templates[] = 'header.php';

这段程序判断 $name 是否不空,如果不空则给$templates[]赋值"header-{$name}.php“

但又紧接着$templates[] = 'header.php'; 那么templates最终就是header.php。

那前面的判断有何作用?
------解决思路----------------------
$templates[];//是给数组添加一个值,不是赋值;
所以在$name != ''的时候,$templates数组内有两个值
  相关解决方案