php file()方法在服务器中不起作用

I am using HTTP API in my application. When I am calling that URL using file() method it is working fine in localhost but not in server.

I am using centos server.

In Command prompt :

#telnet www.example.com

it is getting resonse throw terminal but not in browser

Code :

<?php 
 $url = "http://www.example.com";
 $arr = file($url);
 echo '<pre>';
 print_r($arr);
 echo '</pre>';
?>

You probably have allow_url_fopen disabled on the server. Enable it to get your code to work.

From php.net documentation:

A URL can be used as a filename with this function if the fopen wrappers have been enabled. See fopen() for more details on how to specify the filename.

And here is explanation about fopen wrappers: http://www.php.net/manual/en/filesystem.configuration.php#ini.allow-url-fopen

Check your php.ini and find allow_url_fopen option. It should be enabled to use this functionality