There are many ways to pass parameters in php:
The first one:
Use Client browser cookie. A cookie is easy to understand. It is a temporary file. You can think of it as a storage room. The browser records some information during the browsing process and temporarily stores it here. (Recommended learning: PHP video tutorial)
Second type:
Use server-side session. Understanding session is very easy. The difference from a cookie is that it is a temporary storage on the server side. Session is often called a session.
Set a session in page01.
Third option:
Use a form to pass.
page01.php is written like this:
The code is as follows:
<form action="page02.php" method="post"> <input type="text" name="wuziling" /> <input type="submit" name="submit" value="提交" /> </form>
The attribute action in the form directly specifies which form content is passed to page. method specifies the method of transfer. post stands for using messaging, just like how we send text messages.
page02.php is written like this:
The code is as follows:
<?php $wu = $_POST['wuziling']; echo $wu; ?>
Use $_POST[] to get the passed variable value. This variable name wuziling is defined in the name attribute of the form's input tag.
Then pass it to another variable $wu. So we can output. Direct output is also possible, echo $_POST['wuziling'];
[The value of method can also be get]
Fourth method:
Use hyperlinks to pass parameters. Many of our online operations involve clicking on hyperlinks to jump between web pages. Parameters can also be passed while clicking.
The above is the detailed content of How to pass parameters in php. For more information, please follow other related articles on the PHP Chinese website!