How to pass parameters when php page jumps

王林
Release: 2023-03-03 17:12:01
Original
4851 people have browsed it

How to transfer parameters by php page jump: You can transfer parameters between pages by using the server-side session. Session is a temporary storage room on the server side, often called a session. To use a session, you must start the session through the session_start() statement.

How to pass parameters when php page jumps

# You can use the server-side session.

(Recommended tutorial: php graphic tutorial)

The difference between session and cookie is that it is a temporary storage room on the server side. Session is often called a session.

Set a session in page01.

The code is as follows:

Copy after login

To use session, session must be started. session_start(); is the method to start the session. Generally it should be written first.

In the second statement, I defined a $_SESSION["temp"] array. The name of the array is $_SESSION["temp"], which stores 3 strings.

Accept session on page02.

(Video tutorial recommendation: php video tutorial)

The code is as follows:

';
     }
?>
Copy after login

First start the session. After startup, the variables we defined in page01 are already available and do not require any other acquisition operations. This is different from cookies.

Below we use a for loop to output its content.

Note:

Don’t think that $_SESSION['temp'][$i] is a two-dimensional array, it is a one-dimensional array, and the name of the array is $_SESSION["temp"] , although the name is cumbersome, the subscript of the array is 'temp'.

When we write $_SESSION["temp"], temp plus double quotes or single quotes are equivalent.

Here we define an array when defining session variables, or we can define ordinary variables.

The above is the detailed content of How to pass parameters when php page jumps. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
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 [email protected]
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!