Author: Chinese Red Wolf
Body:
Earlier ("Talking about PHP Syntax (2)") mentioned in the PHP submission form information is very convenient. But how long is the life cycle of a variable in a form information that is submitted? This article will come to Queensland to talk about this problem.
There is no doubt that the parameters of the form are passed to the next handler. Because, we have had such an example. But will it continue to pass to the next handler?
The answer is NO! The parameters submitted by a form form are passed to the first handler, and it does not work in the next handler. Let's take a look at the following example:
File: table.html
<body>
<form action= "deal-1.php" >
Enter what you think is a good singer: <input type= "text" name= "Start" size=20 >
<input type= "Submit" value= "It's him, send it out" >
</form>
</body>
File: deal-1.php
<?php
echo "echo "You like $start, right?" <br> ";
echo "<a href=\" deal-2.php\ "> try whether it will pass again </a>";
echo "</body>?>
File: deal-2.php
<?php
echo "echo "Would you say $start?" ";
echo "</body>?>
From the example above, we can see that the result of deal-1.php processing is (assuming that we entered "Jacky" in Table.html):
You like Jacky Cheung, don't you?
Try to see if it's going to pass again.
Note that the form submitted the variable $start to deal-1.php, and in deal-1.php's display, if we clicked on the link "try to pass again", deal-2.ph Queensland P's processing results are:
Do you have a deal?
Obviously, $start didn't pass to deal-2.php. But how do we prolong the life cycle of $start? In fact, this is very simple, using the method of parameter passing is OK. Like Queensland, we can change the deal-1.php to this:
<?php
echo "echo "You like $start, right?" <br> ";
echo "<a href=\" deal-2.php?start= $start \ "> Try whether it will pass again </a>";
echo "</body>?>
The blurring program, you will find only after the deal-1.php added a "start= $start" on the line, and this function is the parameter pass. For example: Http://zhuagk12.oso. Queensland com.cn/cartoon.php?no=1 The argument, no is the parameter name, and the value is 1. In this way, the variable $no is generated in the cartoon.php program, with a value of 1. If you pass more than two Queensland parameters, it is separated by &. such as: http://zhuagk12.oso.com.cn/cartoon.php?no=2&debug=1
In order to prolong the life cycle of the parameters, we can also use cookies or session to implement, not to add here, in future articles you will see their use.
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