PHP syntax (3)

Source: Internet
Author: User
Talk about PHP syntax (3), read about PHP syntax (3), author: Hua Honglang text: above (talk about PHP syntax (2) it is very convenient to submit the form information in PHP. But how long is the lifecycle of the variable in the submitted form information? This article will talk about this issue. The form parameters are passed to the next handler, which is unquestionable. Because "> <LINKhref =" http://www.p author: Hua Honglang
Body:
As mentioned above (PHP syntax (2), it is very convenient for PHP to submit form information. But how long is the lifecycle of the variable in the submitted form information? This article will talk about this issue.
The form parameters are passed to the next handler, which is unquestionable. Because we have had such an example. But will it still be passed to the next handler?
The answer is No! The parameters submitted by a Form are only transmitted to the first handler, which does not work in the next handler. Let's take a look at the following example:
File: table.html

Form submission






File: deal-1.php
Echo"";
Echo "you like $ start, right?
";
Echo "try again ";
Echo"";
?>
File: deal-2.php
Echo"";
Echo "would you say $ start? ";
Echo"";
?>
From the above example, we can see that the result of deal-1.php processing is (we entered "Zhang Xueyou" in table.html "):

Do you like Zhang Xueyou, right?
Try again

Note that the form commits the variable $ start to the deal-1.php, and in the display result of the deal-1.php, if we click the link "Try Again", the processing result of the deal-2.ph lead p is:

Do you say yes?

Obviously, $ start is not passed to deal-2.php. But how can we extend the lifecycle of $ start? In fact, this is very simple, just use the parameter transfer method. For example, under the license, we can change the deal-1.php to this:
Echo"";
Echo "you like $ start, right?
";
Echo "try again ";
Echo"";
?>
Minute program, you will find that just added a sentence after the deal-1.php "? Start = $ start ", and the role of this operation is parameter transfer. Such as: http://zhuagk12.oso. export com.cn/cartoon.php? No = 1 its? And no is the parameter name. The value is 1. In this way, $ no is generated in the cartoon. php program, and its value is 1. If two or more signature parameters are input, separate them. Such as: http://zhuagk12.oso.com.cn/cartoon.php? No = 2 & debug = 1
We can also use cookies or sessions to extend the lifecycle of parameters. we will not describe them here. you will see their usage in future articles.

-- (To be continued )--

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.