1000字范文,内容丰富有趣,学习的好帮手!
1000字范文 > php file_get_contents返回空 无效解决办法

php file_get_contents返回空 无效解决办法

时间:2021-07-20 15:01:13

相关推荐

php file_get_contents返回空 无效解决办法

php教程|php手册

file_get_contents返回空

php教程-php手册

file_get_contents函数多用来于来采集远程服务器上的内容,但使用file_get_contents函数之前我们在php.ini中是必须把allow_url_fopen开启才行

商业源码赚钱,ubuntu 网页放视频,豆瓣电影详情爬虫,php 定义字符,超排SEOlzw

问题描述:

商城 sqlserver源码,ubuntu的kde优化,tomcat7端口号在哪改,app爬虫京东抢购,php微信支付教程详细图解学习,破天seolzw

fopen(),file_get_contents(),getimagesize() 等都不能正常获得网络上的内容,具体表现为凡参数是URL的,一律返回空值.

八卦源码,vscode快捷键查找函数,ubuntu依赖库,tomcat查看内存使用,爬虫 502错误,电影种子php,临沂济南seo优化如何做lzw

如果是windows可找开 allow_url_fopen开启,如果是否linux中可以重新编译PHP,去掉-with-curlwrapper 参数——编译前记得先执行 make clean.

windows 在未开启allow_url_fopen时我们利用如下代码:

<?php $file_contents = file_get_contents("/"); echo $file_contents;

是获取不到值的,但我们可以利用function_exists来判断此函数是否可用,代码如下:

<?phpfunction file_get_content($url) { if (function_exists(file_get_contents)) { $file_contents = @file_get_contents($url); } if ($file_contents == \) { $ch = curl_init(); $timeout = 30; curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout); $file_contents = curl_exec($ch); curl_close($ch); } return $file_contents;}

本文地址:

转载随意,但请附上文章地址:-)

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。