0

I need to include an HTML file inside of a PHP file. The HTML file contains the following:

  <div id="slideshow">
    <ul>
      <li>
        <img src="http://farm6.static.flickr.com/5270/5627221570_afdd85f16a_z.jpg" alt="" title="Light Trails" />
      </li>

      <li>
        <img src="http://farm6.static.flickr.com/5146/5627204218_b83b2d25d6_z.jpg" alt="" title="Bokeh" />
      </li>

      <li>           
        <img src="http://farm6.static.flickr.com/5181/5626622843_783739c864_z.jpg" alt="" title="Blossoms" />
      </li>

      <li>           
        <img src="http://farm6.static.flickr.com/5183/5627213996_915aa49939_z.jpg" alt="" title="Funky Painting" />
      </li>

      <li>           
        <img src="http://farm6.static.flickr.com/5182/5626649425_fde8610329_z.jpg" alt="" title="Vintage Chandelier" />
      </li>                          
    </ul>
  </div>   

  <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js"></script>
  <script src="/slideshow/js/craftyslide.min.js"></script>

  <script>
    $("#slideshow").craftyslide();
  </script>

To include the HTML file I'm using this PHP statement:

<?php include ('http://nicksgroent.dk/slideshow/demo.html' ); ?>

However this doesn't work.

Frederick Andersen
  • 304
  • 1
  • 6
  • 18

4 Answers4

3
<?php echo file_get_contents('http://nicksgroent.dk/slideshow/demo.html'); ?>
voodoo417
  • 11,861
  • 3
  • 36
  • 40
1

You might have remote inclusion turned off. (allow_url_include) As per the link, however, this is not the ideal way to include a remote file. You'd be better off using file_get_contents or CURL.

See https://stackoverflow.com/a/1158392/1324019.

Community
  • 1
  • 1
Mansfield
  • 14,445
  • 18
  • 76
  • 112
0

if allow_fopen_url is enabled

$content = file_get_contents('http://nicksgroent.dk/slideshow/demo.html');
echo $content;

or curl

$ch = curl_init('http://nicksgroent.dk/slideshow/demo.html');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$content = curl_exec($ch);
curl_close($ch);
echo $content;
Minimihi
  • 408
  • 2
  • 11
0

include expects php files and parses as such, try the following;

$page = file_get_contents('http://nicksgroent.dk/slideshow/demo.html');
echo $page;
Dave
  • 991
  • 1
  • 7
  • 15