/* This example assumes that www.example.com is configured to parse .php
* files and not .txt files. Also, 'Works' here means that the variables
* $foo and $bar are available within the included file. */
// Won't work; file.txt wasn't handled by www.example.com as PHP
include '//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 '//www.example.com/file.php?foo=1&bar=2';
$foo = 1;
$bar = 2;
include 'file.txt'; // Works.
include 'file.php'; // Works.
URL fopen wrappers have to be enabled. Look for allow_url_fopen in your php.ini if you have access to it, and make sure it's set to 1. This is usually enabled by default, so it all depends on what version of PHP you're using, and which platform. If your server is Windows and PHP is version less than 4.3, you're out of luck, because include doesn't support fopen wrappers on that platform and in that version.
I'm on Apache 1.3.34 (Unix) and PHP 4.3.11.
I don't think I have access to php.ini but say that it is set to 1, am I doing anything wrong?
Just tried this also, but that's not working either
Well, that's SSI as I'm sure you know, and not PHP, and your server has to support that as well to work. As far as the include thing goes, you're not really saying what the problem is, just that it doesn't work. I assume you just aren't seeing the included file, and you're not getting any error messages.
In a test file, add this code:
Load the test file into your browser. You'll see the PHP enviornment information. Search for allow_url_fopen (should be right near the top). If it is off, trying to include URLs with the "include" directive won't work. It is indeed a security issue, so I wouldn't be surprised if your host has turned it off.
Louis, if you're still around I've just got around to revisiting this.
Created a test file:
//www.samchadwickphoto.com/test.htm but you'll see that the page is blank.
I don't know PHP well but have you tried the require or require_once verbs instead of include? The include could be authority or it might also be that you don't have the full server path correct (hard to say without any errors). The require_once verb I used just required a relative position from the public htmp folder (default root) - not the path.
when trying to mess with my page (phpNuke) when adding certain things in php in an html page I have to use a " \ " (no quotes) before any "statements."