您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

请教一段wordpress 语句的意思

2024/5/5 1:54:20发布17次查看
$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数组内有两个值
$templates[];//是给数组添加一个值,不是赋值;
所以在$name != ''的时候,$templates数组内有两个值
谢谢,送分,结贴。
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product