faqts : Computers : Programming : Languages : PHP

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

2 of 6 people (33%) answered Yes
Recently 2 of 6 people (33%) answered Yes

Entry

can require() or include() contain Http path? How can we include files in http path format?

Mar 20th, 2008 17:28
ha mo, Dawit Abraham, Hamed Homaei Rad, http://www.php.net/include/


If "URL fopen wrappers" are enabled in PHP (which they are in the 
default configuration), you can specify the file to be included using 
a URL (via HTTP or other supported wrapper - see Appendix L for a list 
of protocols) instead of a local pathname. 
WARNING:
Windows versions of PHP prior to PHP 4.3.0 do not support accessing 
remote files via this function, even if allow_url_fopen is enabled. 
<?php
/* 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 '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';
// Works
require 'http://www.example.com/file.php';
$foo = 1;
$bar = 2;
include 'file.txt';  // Works.
include 'file.php';  // Works.
?>
http://www.tantofa.com
http://www.fantofa.com
http://www.mantofa.com
http://www.tanpola.com
http://www.tampola.com
http://www.yamot.com
http://www.mozmar.com
http://www.templatestemp.com