包括$ page;不工作

时间:2011-02-18 08:11:37

标签: php

您好 我把它包含在我的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

3 个答案:

答案 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.

更多请看这里: http://php.net/manual/en/function.include.php

答案 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(使用)