Jump to content

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.