How to pass parameters in php

(*-*)浩
Release: 2023-02-25 19:34:01
Original
8170 people have browsed it

There are many ways to pass parameters in php:

How 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>
Copy after login

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[&#39;wuziling&#39;];
echo $wu;
?>
Copy after login

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!

Related labels:
php
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!