PHP中的get_file_contents和范围问题

Mar*_*son 0 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 {
        //404
    }
}

echo $_page;
Run Code Online (Sandbox Code Playgroud)

现在,问题是file_get_contents没有返回任何内容:不是false,不是字符串,nada(文件不是空的).

执行确实进入if和$部分(对应于具有相对路径的文件名)不仅设置,但它实际上指向文件.

为什么$ _page是空的(而不是设置,isset($ _ page)实际评估为TRUE)?

编辑:错误报告在我的服务器上全速,并且日志显示没有任何异常.

cod*_*ict 5

您没有保存以下的返回值file_get_contents:

$_page . file_get_contents($part);
Run Code Online (Sandbox Code Playgroud)

我想你想说:

$_page .= file_get_contents($part);
Run Code Online (Sandbox Code Playgroud)