Jump to content

[SOLVED] include function


websteve

Recommended Posts

I am being told that php 5 has additional security when using the include function.. I ran some tests and found that I can only reference parameters that are in the same directory as the file that uses the include, but if I use absolute addressing, it doesn’t work.

 

Here's the code:

 

<?php include('logo.php'); ?>  This works

 

<?php include('http://long-island-real-estate-agency.com/HomesForSale/homes-frame.htm'); ?> This doesn't work

 

How can I use include to reference external URLs?

 

Thanks

 

- Steve

 

Link to comment
https://forums.phpfreaks.com/topic/52205-solved-include-function/
Share on other sites

You can't. But if it's just the output you're after (i.e. the HTML code on that page, which you want on your page) use something like this:

 

<?php

$homesframe = file_get_contents("http://long-island-real-estate-agency.com/HomesForSale/homes-frame.htm");

echo $homesframe;

?>

I am being told that php 5 has additional security when using the include function.. I ran some tests and found that I can only reference parameters that are in the same directory as the file that uses the include, but if I use absolute addressing, it doesn’t work.

 

Here's the code:

 

<?php include('logo.php'); ?>  This works

 

<?php include('http://long-island-real-estate-agency.com/HomesForSale/homes-frame.htm'); ?> This doesn't work

 

How can I use include to reference external URLs?

 

Thanks

 

- Steve

 

Your are correct that php5 comes with additional security. As of PHP5.2 php has included a new setting called allow_url_include. This setting by default is disabled and thus you can not use the latter include.

 

I would recommend chigley's suggestion for using file_get_contents.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.