php - PHP - File_get_contents 在远程服务器上不起作用
问题描述
file_get_content 在运行 php 5.6 的远程服务器上不起作用。
我做了一个测试脚本,只是调用 file_get_contents(' https://google.com ') 它给了我以下错误:
Fatal error: Allowed memory size of 1073741824 bytes exhausted (tried to
allocate 319144 bytes) in FILE_PATH on line 14
<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
ini_set('memory_limit', '1024m');
//$opts = array('http'=>array('header' => "User-Agent:MyAgent/1.0\r\n"));
//$context = stream_context_create($opts);
echo "<pre>";
print_r(file_get_contents("https://google.com"));
echo "</pre>";
echo "test";
//$w = stream_get_wrappers();
//echo 'openssl: ', extension_loaded ('openssl') ? 'yes':'no', "\n";
//echo 'http wrapper: ', in_array('http', $w) ? 'yes':'no', "\n";
//echo 'https wrapper: ', in_array('https', $w) ? 'yes':'no', "\n";
//echo 'wrappers: ', var_export($w);
?>
我用谷歌搜索过,大多数解决方案都改变了
allow_url_fopen 为 1/on 或增加内存限制,我都做了无济于事。
此外,如果我添加标题它可以工作,但它以前不需要它。
任何帮助都会非常感激。
此外,它的运行:nginx/1.6.2 Apache/2.2.22
解决方案
推荐阅读
- r - 清理在我的数据前面具有随机 0 和空格但在数据帧中分布不一致的数据
- python-3.x - PIL:打开透明png时如何设置颜色背景
- go - Go 包全局变量在导入中的使用
- angular - 将 JSON 模型转换为 primeNg p-tree 节点 Angular
- javascript - 如何在猫鼬中使用引用对象的属性?
- python - 如何比较 Faster RCNN 对象检测模型中的训练和测试性能
- javascript - 未捕获的 TypeError:.toFixed() 方法不是函数
- python - python中非线性向量函数的求根:如何对变量设置界限?
- reactjs - 使用 create-react-app 自定义 webpack 插件
- c# - 如何使用 event_category 和 event_label 查询 Google Analytics Data API (GA4)?