Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

PHP's method of creating arrays and url can pass array parsing

2025-03-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Network Security >

Share

Shulou(Shulou.com)06/01 Report--

Question:

Why you can pass arrays in the form of url?a [] = 123 in url.

The origin of the problem:

The problem comes from a vulnerability in the hash function, which can be exploited when the function deals with arrays. The passing array needs to be passed in url. At that time, I didn't know enough about php, and the form of the array only knew the form of array ().

Problem solving: you should first understand several forms of creating arrays in PHP. A brief introduction is given below.

First kind

$array= ('$key1'= >'$value1','$key2'= >'$value2'.)

This format requires the user to specify keys and values in the array.

For example:

Output result

The second kind

$array=array ('value1','value2')

This format does not require the user to specify a key name, just a value. The key name is automatically created, the key name is a number, and it is added from zero to the next.

For example:

Output result:

The third kind

C ['key1'] =' value1'

This format places the key in square brackets and assigns the value directly with the equal sign.

For example:

Output result:

The fourth kind

$d [] = 'value'

In this way, you don't even have to write the keys in parentheses, you can just assign values. The name of the key accumulates from zero to the key of each value.

For example:

Output result:

The most basic way to create an array should be so many, of course, the first method and the third method give a key name that is not necessarily a character or a string, but also an integer.

/ /

The transfer of the array in url:

In order to make the background processing file think that I am passing an array when the url is passed, you can use the fourth method.

When you use the array () function to create an array and pass it, the default is that you are passing a string

For example:

Pass the parameter username=array ('yaun') result:

Returns a string

When using the fourth method, pass the parameter username [] = yaun

Returns an array

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Network Security

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report