search
HomeBackend DevelopmentPHP ProblemHow to pass parameters when php page jumps

How to pass parameters when php page jumps

Aug 01, 2020 pm 01:51 PM
phpparameterpage

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:

<?php 
session_start();
$_SESSION["temp"]=array(&#39;123&#39;,&#39;456&#39;,&#39;789&#39;);
?>

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:

<?php 
     session_start();
     for($i=0;$i<3;$i++)
     {
             echo $_SESSION[&#39;temp&#39;][$i].&#39;<br />&#39;;
     }
?>

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!

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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)