How to get php parameters with special symbols such as # in the URL

小云云
Release: 2023-03-21 15:48:01
Original
3876 people have browsed it

This article mainly introduces to you the solution for PHP to obtain parameters with # and other special symbols in the URL. This article uses the escape function in JS to encode and pass to solve this problem. Friends who need it can refer to it. I hope it can help everyone. .

Today I encountered a front-end using vle.js with a # path. It needs to be transferred to the backend interface to obtain parameters, and then the interface url returns the current page.
The url that the front end will return is escaped today. Function escape
keys = escape(keys); //Encode the string, except * @ - _ + . / these characters
Processing on the php side, use the php get url function to first get the current url path, Convert it back through the rawurldecode function
$aurl = rawurldecode($aurl);
$url = explode('url=',$aurl)[1];
This way you can use the # sign in the url Jumped

Busy first is an example of function usage:

For example, the following PHP code:

Copy after login

When the url is http://test.com/ When c.php?key=999, the normal output is: 999
When the url is http://test.com/c.php?key=9#888, it can only output: 9
and I want I got 9#888, what should I do? We can only find a way to pass 9#888 to the key.
I solved this problem by encoding and passing the escape function in JS. Friends in need can refer to it.

 查询 
Copy after login

Related recommendations:

Detailed explanation of how to obtain the url instance in php

PHP regular matching code to obtain the domain name in the URL

php Get the file extension in the url

The above is the detailed content of How to get php parameters with special symbols such as # in the URL. 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 admin@php.cn
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!