PHP中get_file_内容和作用域的问题
当我开发网站时,我使用一个非常(非常)简单的页面创建系统:PHP中get_file_内容和作用域的问题,php,scope,file-get-contents,Php,Scope,File Get Contents,当我开发网站时,我使用一个非常(非常)简单的页面创建系统: //$_page is, of course, declared above the loop, just as $needed_modules is. foreach ($needed_modules as $part) { global $_page; if (file_exists($part)) { $_page . file_get_contents($part); } else
//$_page is, of course, declared above the loop, just as $needed_modules is.
foreach ($needed_modules as $part)
{
global $_page;
if (file_exists($part)) {
$_page . file_get_contents($part);
} else {
//404
}
}
echo $_page;
现在,问题是file\u get\u内容不返回任何内容:not false,not string,nada(并且该文件不是空的)
如果和$part(对应于具有相对路径的文件名)不仅被设置,而且它实际上指向文件,那么执行确实会进入内部
为什么$\u页面是空的(与设置相反,isset($\u页面)的计算结果实际上是TRUE
)
编辑:在我的服务器上,错误报告处于全速运行状态,日志显示没有异常。您没有保存文件获取内容的返回值。
:
$_page . file_get_contents($part);
我想你是想说:
$_page .= file_get_contents($part);
您没有对返回的值执行任何操作。试试这个:
$_page .= file_get_contents($part);
哦。现在我感到可笑的羞愧。哦,好吧。非常感谢。o/Och hey ho,märkte väl att du skrev påsvenska(Ochär från kalmar med!):)