PHP - include() file not working when variables are put in url?(PHP - 将变量放入 url 时,include() 文件不起作用?)
问题描述
在 PHP 中,我构建了一个使用 include() 加载网站部分的网页.但是,我现在遇到了类似的问题:当我使用如下网址时:data-openov-storingen.php?type=actueel它给了我这个错误:
In PHP I've build a webpage that uses include() for loading parts of the website.
However, I now ran into something like a problem:
When I use an url like: data-openov-storingen.php?type=actueel
It gives me this error:
Warning: include(data-storingen.php?type=actueel): failed to open stream: No such file or directory in blablabla
是否可以在 include() url 中传递 get 变量?
Is it even possible to pass get variables in an include() url?
推荐答案
include() 函数不通过 HTTP 访问文件,它通过操作系统自己的文件系统访问文件.所以 GET 变量不计算在内.(因为它们不是文件名的一部分).
The include() function does not access the file via HTTP, it accesses the file through the OS's own file system. So GET variables are not counted. (as they are not part of the file name).
通俗地说,include 的目的是将一个文件上的所有内容复制/粘贴"到另一个文件上,这样您就不会拥有一个巨大的文件,而是一些更小、更易于维护的文件.
In layman's terms, the point of include is to "copy/paste" all the contents on one file to another on the file, so that you don't have one gigantic file, but a few smaller, more maintainable ones.
这篇关于PHP - 将变量放入 url 时,include() 文件不起作用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:PHP - 将变量放入 url 时,include() 文件不起作用?
基础教程推荐
- Web 服务器如何处理请求? 2021-01-01
- 使用 scandir() 在目录中查找文件夹 (PHP) 2022-01-01
- php中的PDF导出 2022-01-01
- php中的foreach复选框POST 2021-01-01
- php 7.4 在写入变量中的 Twig 问题 2022-01-01
- PHPUnit 的 Selenium 2 文档到底在哪里? 2022-01-01
- 将变量从树枝传递给 js 2022-01-01
- 如何在数学上评估像“2-1"这样的字符串?产生“1"? 2022-01-01
- Yii2 - 在运行时设置邮件传输参数 2022-01-01
- 主题化 Drupal 7 的 Ubercart “/cart"页 2021-01-01
