include()能够包含一个绝对路径的php页面吗?

javaman22 2004-04-08 05:57:24
本地的一张php页面..要include()一张不是本地服务器的php页面...

能够实现吗...

我在PHP手册里面看到这个例子...不知道怎么用


警告
Windows 版本的 PHP 在 4.3.0 版之前不支持该函数的远程文件访问,即使 allow_url_fopen 选项已被激活。


例子 11-5. 通过 HTTP 进行的 include()

<?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';

$foo = 1;
$bar = 2;
include 'file.txt'; // Works.
include 'file.php'; // Works.

?>

相关信息参见使用远程文件,fopen() 和 file()。

因为 include() 和 require() 是特殊的语言结构,在条件语句中使用必须将其放在语句组中(花括号中)。

...全文
606 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
countstars 2004-04-08
  • 打赏
  • 举报
回复
那你为什么不直接放你服务器呢?
就是说,设置该文件不被php解释器解析,可能还可以,具体的不清楚,没测试过,
包含进来以后用exec运行试试。
javaman22 2004-04-08
  • 打赏
  • 举报
回复
To countstars(深空)

对方服务器把php文件设为文本是什么意思...

我该如何要求对方操作操作呢?

谢谢!
countstars 2004-04-08
  • 打赏
  • 举报
回复
除非那个服务器设置php文件为文本可能有可能
countstars 2004-04-08
  • 打赏
  • 举报
回复
不行
javaman22 2004-04-08
  • 打赏
  • 举报
回复
如果是

<?php

include ("http://www.xxx.com/functions.php")

?>

我能直接调用这张functions.php里面的函数??

不可以的吧....
52juanjuan 2004-04-08
  • 打赏
  • 举报
回复
可以如:<?
include("d/wwww/abcd/adbc.php");
?>
这个是肯定的
javaman22 2004-04-08
  • 打赏
  • 举报
回复
能告诉我上面的例子说明了什么吗??

21,886

社区成员

发帖
与我相关
我的任务
社区描述
从PHP安装配置,PHP入门,PHP基础到PHP应用
社区管理员
  • 基础编程社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧