Home  >  Article  >  Backend Development  >  How to pass parameters in php

How to pass parameters in php

(*-*)浩
(*-*)浩Original
2019-10-08 10:13:498233browse

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>

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

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!

Statement:
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