Php faq _ PHP Tutorial

Source: Internet
Author: User
Php faq. In versions later than PHP4.2, the default value of register_global is off. if you want to get the variable submitted from another page: Method 1: in PHP. find register_global in ini and set it to on. method 2:

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 beginning of the receiving page. (note that 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.

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"
";
?>

Why do I get only the first half when I send a variable to another web page, and all the variables starting with a space are lost?

PHP code:
$ Var = "hello php"; // change it to $ Var = "hello php"; what are the results?
$ Post = "receive. php? Name = ". $ Var;
Header ("location: $ post ");
?>


Content of receive. php:

PHP code:
Echo "
";
Echo $_GET["Name"];
Echo "
";
?>


The correct method is:

PHP code:
$Var="hello php";
$post= "receive.php?Name=".urlencode($Var);
header("location:$post");
?>


You do not need to use Urldecode () on the receiving page. the variable is automatically encoded.

Standardize your SQL statements
In the table, add "'" before the field so that it will not be misused.

If you want to obtain the variable submitted from another page: Method 1: Find register_global in PHP. ini and set it to on. Method 2: connect...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.