I am using the following code

<?php

$url="http://www.google.com";

$data = file_get_contents( $url );

echo $data;

echo strlen($data);

?>

It works well on my local host but when i upload it to my web domain, file_get_contents gives an empty string as output.

Why this happens? Any idea to solve this problem

    Add this to the start of the code to see if it tells you why:

    <?php
    ini_set('display_errors', 1);  // set to 0 for production version
    error_reporting(E_ALL);
    
    // rest of code...
    ?>
    

    It may be that your host is configured with [man]allow_url_fopen[/man] turned off.

      After adding your prescribed code, i got the following error revealed :

      Warning: file_get_contents(http://www.google.com) [function.file-get-contents]: failed to open stream: Permission denied in /home/www/blinkideas.freehostia.com/anus/jack.php on line 13

        Curl also does not work.

        i have got another free domain where such file_get_contents work but the problem is , there strstr function does not work. it gives error "wrong parameter".

        i dont know what happens there. when i use this file on local host it works perfectly.

        Any idea to solve this problem ?

        or anyone know any free domain host where all php functions are supported ???

          Write a Reply...