Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/lua/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PHP中get_file_内容和作用域的问题_Php_Scope_File Get Contents - Fatal编程技术网

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!):)