Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Check <a href="http://php.net/file_get_contents" rel="noreferrer"><code>file_get_contents</code> <sup><strong>PHP Manual</strong></sup></a> return value. If the value is <code>FALSE</code> then it could not read the file. If the value is <code>NULL</code> then the function itself is disabled.</p> <p>To learn more what might gone wrong with the <code>file_get_contents</code> operation you must enable error reporting and the display of errors to actually read them.</p> <pre><code># Enable Error Reporting and Display: error_reporting(~0); ini_set('display_errors', 1); </code></pre> <p>You can get more details about the why the call is failing by checking the INI values on your server. One value the directly effects the <code>file_get_contents</code> function is <a href="http://www.php.net/manual/en/filesystem.configuration.php#ini.allow-url-fopen" rel="noreferrer"><code>allow_url_fopen</code></a>. You can do this by running the following code. You should note, that if it reports that fopen is not allowed, then you'll have to ask your provider to change this setting on your server in order for any code that require this function to work with URLs.</p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;title&gt;Test File&lt;/title&gt; &lt;script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"&gt; &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;?php # Enable Error Reporting and Display: error_reporting(~0); ini_set('display_errors', 1); $adr = 'Sydney+NSW'; echo $adr; $url = "http://maps.googleapis.com/maps/api/geocode/json?address=$adr&amp;sensor=false"; echo '&lt;p&gt;'.$url.'&lt;/p&gt;'; $jsonData = file_get_contents($url); print '&lt;p&gt;', var_dump($jsonData), '&lt;/p&gt;'; # Output information about allow_url_fopen: if (ini_get('allow_url_fopen') == 1) { echo '&lt;p style="color: #0A0;"&gt;fopen is allowed on this host.&lt;/p&gt;'; } else { echo '&lt;p style="color: #A00;"&gt;fopen is not allowed on this host.&lt;/p&gt;'; } # Decide what to do based on return value: if ($jsonData === FALSE) { echo "Failed to open the URL ", htmlspecialchars($url); } elseif ($jsonData === NULL) { echo "Function is disabled."; } else { echo $jsonData; } ?&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>If all of this fails, it might be due to the use of short open tags, <code>&lt;?</code>. The example code in this answer has been therefore changed to make use of <code>&lt;?php</code> to work correctly as this is guaranteed to work on in all version of PHP, no matter what configuration options are set. To do so for your own script, just replace <code>&lt;?</code> or <code>&lt;?php</code>.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload