使用include_once和php变量时出错 [英] error using include_once with a php variable

查看:208
本文介绍了使用include_once和php变量时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

//$GLOBAL_includesPath = "http://localhost/smthing/";

    <?
       include_once $GLOBAL_includesPath.'global_menu.php';
    ?>

错误:

警告:include_once()[function.include-once]:http://包装器为 在服务器配置中被allow_url_include = 0禁用 第39行的C:\ xampp \ htdocs \ smthing \ includes \ page_header.php

Warning: include_once() [function.include-once]: http:// wrapper is disabled in the server configuration by allow_url_include=0 in C:\xampp\htdocs\smthing\includes\page_header.php on line 39

警告: include_once(http://localhost/sthing/includes/global_menu.php) [function.include-once]:无法打开流:没有合适的包装器 可以在C:\ xampp \ htdocs \ smthing \ includes \ page_header.php中找到 第39

Warning: include_once(http://localhost/sthing/includes/global_menu.php) [function.include-once]: failed to open stream: no suitable wrapper could be found in C:\xampp\htdocs\smthing\includes\page_header.php on line 39

警告:include_once()[function.include]:打开失败 包含的"http://localhost/smthing/includes/global_menu.php" (include_path ='.; C:\ xampp \ php \ PEAR')在 第39行的C:\ xampp \ htdocs \ smthing \ includes \ page_header.php

Warning: include_once() [function.include]: Failed opening 'http://localhost/smthing/includes/global_menu.php' for inclusion (include_path='.;C:\xampp\php\PEAR') in C:\xampp\htdocs\smthing\includes\page_header.php on line 39

推荐答案

相信我,您不想包含在URL中.

  • 一旦不是本地主机,这将带来巨大的安全风险
  • 包含一个远程PHP文件将包含其输出; PHP代码本身将在远程服务器上执行
  • 如果要输出,请使用curl或file_get_contents()
  • As soon as it's not localhost, it's a huge security risk
  • Including a remote PHP file will include its output; the PHP code itself will execute on the remote server
  • If you want the output, use curl or file_get_contents()

如果您不在乎,只是想让它正常工作(不好!),该错误将告诉您您所需要的一切:在php.ini中启用allow_url_include.

If you don't care and just want it to work (bad!), the error told you all you need: Eenable allow_url_include in your php.ini.

否则,请使用include_once('path/to/your/file/global_menu.php');

这篇关于使用include_once和php变量时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆