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. .
Busy first is an example of function usage:
For example, the following PHP code:
<?php echo $_GET['key']; ?>
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.
<input placeholder="输入SN码" type="text" id="searchs" name="searchs" /> <a class='btn' onclick="searchsn();" href="javascript:;">查询</a> <script> function searchsn() { var keys = $('#searchs').val(); if (keys == '') { alert('请填写SN码'); return false; } keys = escape(keys); //对字符串进行编码,* @ - _ + . / 这几个字符除外 window.location.href = 'c.php?key=' + keys; } </script>
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!