包括$ page; 不工作

Hi I have included this in my index.php

include $page;

but it is not working on live server BUT WORKING FINE on my Localhost. I have also included include ('includes/_ini.php'); on the top of index.php page in which $page is defined. Please suggest

On server it giving the following WARNING

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

The include() statement includes and evaluates the **specified file**.

Look at your warning:

Warning: include(?pgid=1&parid=&rid=1&lang=1) 

Compare to this (your code)

include $page;

So =>

   $page = ?pgid=1&parid=&rid=1&lang=1

**specified file** not like your format here: ?pgid=1&parid=&rid=1&lang=1 (it is just the URL not the path of existing file)

for example:

/* 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.

More take a look here: http://php.net/manual/en/function.include.php

It seems $page is in url format. Its not the path of file.

You must use path of file to include.

file name must be as

folder/file1.php for linux (use /)

and

folder\file1.php for windows (use )

The warning is clear; $page contains ?pgid=1&parid=&rid=1&lang=1 which is not a valid file name to include. A valid file name would be for example foo/bar.php.