Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
689 views
in Technique[技术] by (71.8m points)

php - fopen is not working on my server

It works perfectly on localhost with Xampp, but when I try it on my server (host-ed.net), fopen can't open any url, it only works for files without http.

<?php
$file="http://www.google.es";
$gestor = fopen($file, "r") or die ("Nothing");
?>

In my server with this code shows Nothing. Can be anything on the php.ini ?

EDIT: In the php.ini: allow_url_fopen = On

EDIT: It's solved. My server had it disabled, but now it's enabled. Thanks for the answers.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

fopen can't open any url

Check the value of the allow_url_fopen php.ini setting:

var_dump(ini_get('allow_url_fopen'));

It's probably false. You'll need to speak to your web host, or try another method. Mabye CURL is enabled?

You should also check your error_reporting and display_errors values. PHP should have complained loudly about being unable to open the URL. You'll want to turn both of them all the way up while developing code, so you can understand what goes wrong easier.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...