Jump to content

Remote (http) include_path


brianamerige

Recommended Posts

Hi all,

 

Basically, I'm running PHP locally, and I need to include a remote (web-accessible) file. Here's a simple example to prove my point of what I  need to effectively do:

<?php
set_include_path(".:http://somesite.com/aPath");
include("aFile.php"); //afile.php is at http://somesite.com/aPath/afile.php
?>

 

Of course, this errors with:

Warning: main(): Failed opening 'aFile.php' for inclusion (include_path='.:http://somesite.com/aPath') in /private/var/tmp/FlowEditorPHPTemp.php on line 3

 

Initially, I'd have thought this impossible. But then to my surprise, include() works with remote (web accessible) files:

<?php
include("http://somesite.com/aPath/afile.php"); 
?>

 

Before the obvious is asked ("if you know the include_path you'd like to add, why not just do what's shown above, and do an absolute remote path?), the answer is simple. These are just examples to prove the functionality I'm looking for. The real context of this running this (or similar) command from a unix (Mac Os X, to be specific) terminal:

php -d include_path=.:http://somesite.com/aPath ~/Path/ToLocal/File/With/Relative/include.php

where include.php contains an include() call to a relative file, like this:

include("aFile.php");

 

Any help is truly appreciated!

Link to comment
Share on other sites

I would bet that your problem is with set_include_path as the include path can only apply to the file system

 

include_path = string

 

Specifies a list of directories where the require(), include(), fopen(), file(), readfile() and file_get_contents() functions look for files. The format is like the system's PATH environment variable: a list of directories separated with a colon in Unix or semicolon in Windows.

 

 

try it without the set_include_path

Link to comment
Share on other sites

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.