分页问题(PHP超全局变量问题,未定义索引)

i am trying to implement pagination somewhere and i have this issue:

I have this part to change links:

echo " <a href='$_SERVER[SCRIPT_NAME]?Page=$Prev_Page'><< Back</a> ";  

which gives this error for this part:

$Page = $_GET["Page"];  
if(!$_GET["Page"])  
{  

It says undefined index.. Why do I get this Error? Thanks

You should quote the array index. also use html entities. Like this

echo " <a href='{$_SERVER['SCRIPT_NAME']}?Page=$Prev_Page'>&lt;&lt; Back</a> "; 

And its safe to check if $_GET["Page"] exists.

$Page = isset($_GET["Page"]) ? $_GET["Page"]: false;

This happens because you are missing an index in the array. $_GET is just an array, so you should check if the key exists first.

$Page = (array_key_exists('page', $_GET)) ? $_GET["page"] : false;  
if($Page===false)  
{  
   //no page
   return;
}
// empty() works even if the variable doesn't exist, kind of like isset()
if(!empty($_GET['Page']) !== false) {
    // Do stuff
    $page = $_GET['Page'];
}