include() through HTTP?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
lauthiamkok
Forum Contributor
Posts: 153
Joined: Wed Apr 01, 2009 2:23 pm
Location: Plymouth, United Kingdom

include() through HTTP?

Post by lauthiamkok »

Hi,
Can I include file through HTTP? I tried the example below from http://uk2.php.net/function.include
but it is def not working on my localhost.

Code: Select all

<?php
// Won't work; file.txt wasn't handled by http://www.example.com as PHP
include 'http://www.example.com/file.txt?foo=1&bar=2';
 
// Won't work; looks for a file named 'file.php?foo=1&bar=2' on the
// local filesystem.
include 'file.php?foo=1&bar=2';
 
// Works.
include 'http://www.example.com/file.php?foo=1&bar=2';
 
$foo = 1;
$bar = 2;
include 'file.txt';  // Works.
include 'file.php';  // Works.
 
?>

This is what I tried to include

Code: Select all

<?php include 'http://localhost/mysite/incl_layouts.blog/navigation.php';?>
Instead of

Code: Select all

<?php include("incl_layouts.blog/navigation.php");?>
Many thanks,
Lau
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: include() through HTTP?

Post by Christopher »

You can include via HTTP if your installation is configured to allow it. Remember you will not get the script with the include -- only the output of the remote script.
(#10850)
Post Reply