brianamerige Posted July 23, 2007 Share Posted July 23, 2007 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! Quote Link to comment Share on other sites More sharing options...
tomfmason Posted July 24, 2007 Share Posted July 24, 2007 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 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.