Example: file_get_contents()


Warning: file_get_contents(): https:// wrapper is disabled in the server configuration by allow_url_fopen=0 in /home/clelana5/public_html/citw185/examples/more-string-stuff.php on line 26

Warning: file_get_contents(https://sperling.com): Failed to open stream: no suitable wrapper could be found in /home/clelana5/public_html/citw185/examples/more-string-stuff.php on line 26

fopen is not allowed on this host.


Code follows

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>More String Stuff Example</title>
    <link rel="stylesheet" href="css/styles.css">
</head>
<body>

<div class="page">

    <p class="nav"><a href="../index.php">Home</a></p>


    <?php

    
echo("<h2>Example: file_get_contents() </h2>");

    
ini_set('display_errors', 1);

    
$url = "https://sperling.com";

    
//   $url = "../doc/mytext.txt";

    
$a = file_get_contents($url);

    
$a = strip_tags($a);

    echo(
$a);

    
// Output information about allow_url_fopen:
    
if (ini_get('allow_url_fopen') == 1)
    {
        echo 
'<p style="color: #0A0;">fopen is allowed on this host.</p>';
    }
    else
    {
        echo 
'<p style="color: #A00;">fopen is not allowed on this host.</p>';
    }

    
?>

    <hr>

    <h2>Code follows</h2>

    <div class="code"><?php highlight_file(__FILE__); ?></div>

    <p class="nav nav-foot"><a href="../index.php">Home</a></p>

</div>

</body>
</html>