当前位置:网站首页>PHP background parsing after JQ serialization

PHP background parsing after JQ serialization

2022-04-23 06:51:00 Collect and study by yourself

JQ Serialized data (serialize())

I see it backstage. It's probably "name=chen&sex=1" In this way ,

perhaps JQ Serialize an array with the same name

<input type="text" value="1" name="name[]"/>

<input type="text" value="2" name="name[]"/>

var name = $('input[name="name[]"]').serialize();

What you see backstage is similar "name%5B%5D=1&name%5B%5D=2"

It can be used parse_str() Function analysis

parse_str('name=chen&sex=1');
print_r($name);
echo "<br>";
print_r($sex);
echo "<br>";
parse_str('name%5B%5D=1&name%5B%5D=2');
print_r($name);

The same name will be parsed into an array

Expand the :

stay PHP There is 2 Resolutions URL Function of , Namely parse_str() Functions and parse_url() function , among parse_str The function parses the query string into a variable ,parse_url The function is used to parse the entire URL, And return to its components

$url = "http://www.electrictoolbox.com/php-extract-domain-from-full-url/";
$parts = parse_url($url);

result :

Array (
[scheme] => http
[host] => www.electrictoolbox.com
[path] => /php-extract-domain-from-full-url/
)

版权声明
本文为[Collect and study by yourself]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204230555552257.html