require 和 echo blanc 文件后出现奇怪的“1”数字
Freak "1" number appear after require and echo blanc file
我有一个非常奇怪的问题:-)
请看这个简单的网站:
http://tests.vipserv.org/
有...“1”个数字。但是在代码中没有任何“1”...
我将 eol 转换为 Unix。没有结果。还将编码更改为 UTF with/without boom.
"Website" 是从文件创建的:
index.php:
<?php
class View {
public static $TPL_VIEW = 'view.php';
public static function renderView($template, $data = array()) {
echo require $template;
}
public static function generateView($template, $data = array()) {
return require $template;
}
}
View::renderView(View::$TPL_VIEW, '');
?>
和view.php:
(blanc)
您可以从以下位置下载文件:
谢谢,
答.
echo require $template;
require
returns 如果包含成功与否,即 true 或 false 或 1 或 0。
所以 echo 正在显示它。
你自己在附和。根据 manual:
Handling Returns: include returns FALSE on failure and raises a
warning. Successful includes, unless overridden by the included file,
return 1.
所以代替:
echo require $template;
你可能想要:
require $template;
假设您的模板实际上不应该 return 当然。
我有一个非常奇怪的问题:-)
请看这个简单的网站: http://tests.vipserv.org/
有...“1”个数字。但是在代码中没有任何“1”...
我将 eol 转换为 Unix。没有结果。还将编码更改为 UTF with/without boom.
"Website" 是从文件创建的: index.php:
<?php
class View {
public static $TPL_VIEW = 'view.php';
public static function renderView($template, $data = array()) {
echo require $template;
}
public static function generateView($template, $data = array()) {
return require $template;
}
}
View::renderView(View::$TPL_VIEW, '');
?>
和view.php:
(blanc)
您可以从以下位置下载文件:
谢谢, 答.
echo require $template;
require
returns 如果包含成功与否,即 true 或 false 或 1 或 0。
所以 echo 正在显示它。
你自己在附和。根据 manual:
Handling Returns: include returns FALSE on failure and raises a warning. Successful includes, unless overridden by the included file, return 1.
所以代替:
echo require $template;
你可能想要:
require $template;
假设您的模板实际上不应该 return 当然。