[英]layout.phtml issue in zend framework1
<?php
$this->headMeta()->appendHttpEquiv('Content-Type', 'text/html;charset=utf-8');
$this->headTitle()->setSeparator(' - ');
$this->headTitle('Zend Framework Tutorial');
echo $this->doctype(); ?>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<?php echo $this->headMeta(); ?>
<?php echo $this->headTitle(); ?>
</head>
<body>
<div id="content">
<h1><?php echo $this->escape($this->title); ?></h1>
<?php echo $this->layout()->content; ?>
</div>
</body>
Above code is taken from this tutorial: http://akrabat.com/wp-content/uploads/Getting-Started-with-Zend-Framework.pdf
it is on page 10, file is : zf-tutorial/application/layouts/scripts/layout.phtml
上面的代码摘自本教程:
http://akrabat.com/wp-content/uploads/Getting-Started-with-Zend-Framework.pdf
: http://akrabat.com/wp-content/uploads/Getting-Started-with-Zend-Framework.pdf
它位于第10页,文件为: zf-tutorial/application/layouts/scripts/layout.phtml
Question: 题:
what is this line for? 这条线是做什么用的?
$this->headTitle()->setSeparator(' - ');
why we need this line: <?php echo $this->escape($this->title); ?>
为什么我们需要这一行:
<?php echo $this->escape($this->title); ?>
<?php echo $this->escape($this->title); ?>
I guess 'escape' is for security, but what does it actully mean here? <?php echo $this->escape($this->title); ?>
我猜“转义”是为了安全,但是这里的含义是什么呢?
$this->escape()
By default, the escape() method uses the PHP htmlspecialchars() function for escaping. 默认情况下,escape()方法使用PHP htmlspecialchars()函数进行转义。 Escaping Output
转义输出
$this->headTitle()->setSeparator(' - '); $ this-> headTitle()-> setSeparator('-');
When you add multiple values to a headtitle setSeparator
will seperate the title with the specified seperator. 当您添加多个值到headtitle
setSeparator
将单独与指定的分隔符的称号。 Head Title 头衔
<?php
$request = Zend_Controller_Front::getInstance()->getRequest();
$this->headTitle($request->getActionName())
->headTitle($request->getControllerName());
$this->headTitle('Zend Framework');
$this->headTitle()->setSeparator(' - ');
?>
<?php echo $this->headTitle() ?>
will create <title>action - controller - Zend Framework</title>
<?php echo $this->headTitle() ?>
将创建<title>action - controller - Zend Framework</title>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.