php 在linux 用fopen() 函数打开,file_get_contents(),fread()函数 读取 另外一台服务器映射过来的文件 总是返回false,null的情况。

php 在linux 用fopen() 函数打开,fread()函数 读取  另外一台服务器映射过来的文件 总是返回false,null的情况。

   #获取平台类型
   $type='android';
   #读取文件的路径
   $url="/opt/mobile_system/gscdn";
   $file_name="update.ini";
   $path=$url.'/'.$type.'/'.$file_name;

   #读取php.ini json格式的文件
   $content=json_decode(file_get_contents($path),true);

  或者使用
  $head=fopen($path) //返回false
  $content=fread($head);//返回空
以上两种方式读取都会失败。都会返回空。可能这两种读取方式是读取真实的路径。
------------------------------------------------------------------------------------------
解决办法:
$content=json_decode("http://XXX.XXXX.com/update/wp/update.ini");

var_dump($content);










原文地址:https://www.cnblogs.com/hgj123/p/4500403.html