Pound sign (#) not working in PHP

前端 未结 2 889
心在旅途
心在旅途 2020-12-11 12:23

I have variable \'cno\' and it\'s values sometimes have 123# - ( end with pound sign. )

The problem is, after passing the URL I couldn\'t get variable w

2条回答
  •  萌比男神i
    2020-12-11 13:07

    You'll have to encode the # as %23, so your URL would look like this:

    /index.php?cno=34%23

    To make it easier use PHP's built-in urlencode function: http://php.net/urlencode

    $cno = "34#";
    $url = urlencode("/index.php?cno=" . $cno); // "/index.php?cno=34%23"
    

提交回复
热议问题