您好 我把它包含在我的index.php
中include $page;
但它不能在实时服务器上工作但在我的Localhost上工作正常。
我还在index.php页面的顶部包含了include ('includes/_ini.php');
,其中定义了$page
。
请建议
在服务器上,它提供以下警告
Warning: include(?pgid=1&parid=&rid=1&lang=1) [function.include]: failed to open stream: No such file or directory in /opt/lampp/htdocs/mysite.com/index.php on line 290
Warning: include(?pgid=1&parid=&rid=1&lang=1) [function.include]: failed to open stream: No such file or directory in /opt/lampp/htdocs/mysite.com/index.php on line 290
Warning: include() [function.include]: Failed opening '?pgid=1&parid=&rid=1&lang=1' for inclusion (include_path='.:/opt/lampp/lib/php') in /opt/lampp/htdocs/mysite.com/index.php on line 290
答案 0 :(得分:5)
include()
语句包含并评估**specified file**
。
查看您的警告:
Warning: include(?pgid=1&parid=&rid=1&lang=1)
与此(您的代码)比较
include $page;
So =>
$page = ?pgid=1&parid=&rid=1&lang=1
**specified file**
不像您的格式:?pgid=1&parid=&rid=1&lang=1
(它只是网址而不是现有文件的路径)
例如:
/* 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.
答案 1 :(得分:4)
警告很清楚; $page
包含?pgid=1&parid=&rid=1&lang=1
,它不是要包含的有效文件名。有效的文件名例如是foo/bar.php
。
答案 2 :(得分:2)
似乎$page
采用网址格式。它不是文件的路径。
您必须使用path of file to include
。
文件名必须为
folder/file1.php
的 linux
(使用/)
和
folder\file1.php
windows
(使用)