错误信息Extra content at the end of the document与file_put_contents()函数的因果关系

我在架设服务Web平台时遇到下现这个问题的时候,一直不知道问题出在哪里。
1.平台架构为Centos7.3+Nginx1.16+php7.3.15+mysql8
错误信息Extra content at the end of the document与file_put_contents()函数的因果关系
搭好平台后,运行Web平台时,出现如下错误:错误信息Extra content at the end of the document与file_put_contents()函数的因果关系
在新窗口打开链接后出现如果报错信息:错误信息Extra content at the end of the document与file_put_contents()函数的因果关系
This page contains the following errors:
error on line 2 at column 1: Extra content at the end of the document
Below is a rendering of the page up to the first error.

再查源码,有如下代码:
Warning: file_put_contents(.------cache): failed to open stream: No such file or directory in …………c.php on line 41
提示找不到路经,到网上查原因:
开始以为是XML文档输出不规范,少了根标签,然后去查输出代码……。花了很多时间还是没有解决,此路不通。

后来仔细看此页,发现没有数据输出(我确认数据库是正确连接的,表里也有测试数据),然后就了解到了看到了file_put_contents()这个写入文件的函数,我在想是不是文件没有写成功,是不是WEB相应的目录没有写入权限,于是查看了下目录,是这样的。错误信息Extra content at the end of the document与file_put_contents()函数的因果关系
明显目录写入权限不够啊,网上的解决办法是:
chmod 777 /www 此为WEB的全目录
执行后查看写入权限变化,如下

由原来的drwxr-xr-x 变为 drwxrwxrwx
执行后再测试,问题解决,原来问题是出在WEB相应目录的权限上,导致file_put_contents()函数不能生成缓存XML文件,从而无法正确输出内容出来,才产生This page contains the following errors:
error on line 2 at column 1: Extra content at the end of the document
Below is a rendering of the page up to the first error.
的报错信息。

到此,大功告成。

PS: chmod 777 命令把这个问题找出来了,具体的目录是否需要写入权限得根据需要来定,以增加WEB的安全性。

希望遇到相同问题的伙伴少走弯路…………
此文由sztomjon原创,转载请注明出处。