Home > Article > Backend Development > Summary and answers to frequently asked questions about learning dynamic webpage PHP technology_PHP tutorial
1: Why can’t I get the variable
I POST data name from one web page to another web page, why can’t I get any value when I output $name?
In PHP4.2 and later versions, reGISter_global defaults to off
If you want to get variables submitted from another page:
Method 1: Find register_global in PHP.ini and set it to on.
Method 2: Put this extract($_POST);extract($_GET); at the front of the receiving web page (note that there must be Session_Start() before extract($_SESSION)).
Method 3: Read the variables $a=$_GET["a"];$b=$_POST["b"] one by one. Although this method is troublesome, it is safer.
2: Debug your program
The value of a variable must be known at runtime. This is what I did, create a file debug.php with the following content:
PHP code:
Ob_Start();
Session_Start();
Echo "
";<br> <br> Echo "The _GET variables obtained on this page are:";<br> Print_R($_GET);<br> <br> Echo "The _POST variables obtained on this page are:";<br> Print_R($_POST);<br> <br> Echo "The _COOKIE variables obtained on this page are:";<br> Print_R($_COOKIE);<br> <br> Echo "The _SESSION variables obtained on this page are:";<br> Print_R($_SESSION);<br> <br> Echo "";