包括$ page; 不工作

van*_*rag -3 php

嗨,我把它包含在我的index.php中

include $page;
Run Code Online (Sandbox Code Playgroud)

但它不能在实时服务器上运行,但在我的Localhost上工作正常.我还在include ('includes/_ini.php');index.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
Run Code Online (Sandbox Code Playgroud)

kn3*_*n3l 5

include()声明包括并评估**specified file**.

看看你的警告:

Warning: include(?pgid=1&parid=&rid=1&lang=1) 
Run Code Online (Sandbox Code Playgroud)

与此相比(您的代码)

include $page;
Run Code Online (Sandbox Code Playgroud)

所以=>

   $page = ?pgid=1&parid=&rid=1&lang=1
Run Code Online (Sandbox Code Playgroud)

**specified file**不像你的格式:( ?pgid=1&parid=&rid=1&lang=1它只是URL而不是现有文件的路径)

例如:

/* 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.
Run Code Online (Sandbox Code Playgroud)

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