1: Why can't I get the variable I post the data name to another webpage on one webpage? why can't I get any value when I output $ name? In versions later than PHP4.2, the default value of reGISter_global is off...
1: Why can't I get the variable?
Why can't I get any value when I output $ name when I POST data name to another webpage?
In versions later than PHP4.2, the default value of reGISter_global is off.
To get the variables submitted from another page:
Method 1: Find register_global in PHP. ini and set it to on.
Method 2: Put the extract ($ _ POST); extract ($ _ GET) at the top of the receiving webpage; (focus on extract ($ _ SESSION) you must have Session_Start ()).
Method 3: Read the variable $ a =$ _ GET ["a"]; $ B =$ _ POST ["B"] one by one. Although this method is troublesome, it is safer.
2: debug your program
You must know the value of a variable at runtime. In this case, create a debug. php file with the following content:
PHP code:
Ob_Start ();
Session_Start ();
Echo"
";
Echo "the _ GET variables obtained on this page include :";
Print_R ($ _ GET );
Echo "the _ POST variables obtained on this page include :";
Print_R ($ _ POST );
Echo "the _ COOKIE variables on this page are :";
Print_R ($ _ COOKIE );
Echo "the _ SESSION variables obtained on this page include :";
Print_R ($ _ SESSION );
Echo"
";
?>
Then in php. set in ini: export de_path = "c:/php" and debug. php is placed in this folder, and you can include this file in each web page to view the variable name and value.
3: how to use session
The session_start () function must be called before session-related operations ();
It is very easy to pay for the session, such:
PHP code:
Session_start ();
$ Name = "this is a Session example ";
Session_Register ("Name"); // do not write it as Session_Register ("$ Name ");
Echo $ _ SESSION ["Name"];
// After $ _ SESSION ["Name"] is "this is a Session example"
?>
After php4.2, you can directly pay the value for the session:
PHP code:
Session_Start ();
$ _ SESSION ["name"] = "value ";
?>
You can cancel the session as follows:
PHP code:
Session_start ();
Session_unset ();
Session_destroy ();
?>
There is a BUG in canceling a session variable above php4.2.