fopen returns Resource id #4

前端 未结 4 1998
独厮守ぢ
独厮守ぢ 2021-01-21 15:10


        
相关标签:
4条回答
  • 2021-01-21 15:46

    Because fopen return the resource handle of the file it opened not the contents.

    0 讨论(0)
  • 2021-01-21 15:56

    Because fopen() returns a resource pointer to the file, not the content of the file. It simply opens it for subsequent reading and/or writing, dependent on the mode in which you opened the file.

    You need to fread() the data from the resource referenced in $handle.

    This is all basic stuff that you could have read for yourself on the manual pages of php.net

    0 讨论(0)
  • 2021-01-21 16:03

    Use

    <?php
        $data = file_get_contents("https://graph.facebook.com/search?q=mark&type=user&access_token=2227470867|2.mLWDqcUsekDYZ_FQQXYnHw__.3600.1279803600-100001317997096|YxS1eGhjx2rpNYLNE9wLrfb5hMc.", "r");
        echo $data;
    ?>
    
    0 讨论(0)
  • 2021-01-21 16:08

    Once you have created your $handle you now need to fread() the contents.

    $contents = ''; 
    while (!feof($handle)) 
    { 
    $contents .= fread($handle, 8192); 
    } 
    fclose($handle); 
    echo $contents; 
    

    source: php.net/manual/en/function.fread.php

    0 讨论(0)
提交回复
热议问题