请教一段wordpress 语句的意思

WBOY
Release: 2016-06-23 13:23:15
Original
763 people have browsed it

$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数组内有两个值




谢谢,送分,结贴。
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!