简体   繁体   English

在Joomla中获取文件内容

[英]Get file contents in Joomla

I'm trying to get a file's content into a variable but I don't get anything when I read the file. 我正在尝试将文件的内容放入变量,但读取文件时却什么也没得到。 I used both methods JFile::read() and file_get_contents() but both return the same thing: a blank string, not an error , not any boolean values or anything. 我同时使用了JFile::read()file_get_contents()这两种方法,但是都返回了相同的东西:一个空字符串,不是一个错误,没有任何布尔值或任何东西。

I want to mention that I'm working on a Linux machine (just for 2 days) and recently I changed the permissions for the entire machine to 777 ( I don't know if this affects something or not). 我想提到的是,我在Linux机器上工作(仅2天),最近我将整个机器的权限更改为777(我不知道这是否会影响某些事情)。

Is the a connection between my OS, permissions and the php's file_get_contents() ? 我的操作系统,权限和php的file_get_contents()之间是否存在连接? or Joomla restricts file reading? 或Joomla限制文件读取?

Also I want to mention that my file_get_contents() function was added manually by me in the index.php file , also the file I want to read was manually added in the same folder with index.php . 此外,我想提一提我file_get_contents()函数手动添加由我在index.php文件,我也想读取文件在同一文件夹中手动添加index.php

We had the same problem with one of our clients, it turned out it was a firewall issue. 我们的一位客户遇到了同样的问题,事实证明这是防火墙问题。 It was very hard to debug this issue. 调试此问题非常困难。 I suggest you check with your networking team. 我建议您与您的网络团队联系。

I am assuming, of course, that you have set the PHP error reporting level to the maximum and that you have checked the error logs. 当然,我假设您已将PHP错误报告级别设置为最大,并且已经检查了错误日志。

It seemed the problem was from my system . 看来问题出在我的系统上。 I messed it up when I changed the permissions so I have to re-install it. 更改权限后,我将其弄乱了,因此必须重新安装它。

Never change the permissions on a Linux for the entire file system. 切勿在Linux上更改整个文件系统的权限。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM