![](/img/trans.png)
[英]Remove ASCII Hex Codes for Non-Alphanumeric Printable Characters from URL PHP
[英]in PHP string, how to convert non-alphanumeric characters to ascii in hex
比如怎么寫一個 PHP function 來轉換
http://abc.com/hi-1?source=google
被轉換成
http%3A%2F%2abc.com%2Fhi-1%3Fsource%3Dgoogle
PS有些異常不應該被轉換,比如'.' '-'
謝謝。
http://php.net/manual/en/function.urlencode.php
或者
http://www.php.net/manual/en/function.rawurlencode.php
<?php
$string = "http://abc.com/hi-1?source=google";
echo urlencode($string); //echo rawurlencode($string);
http://php.net/manual/en/function.rawurlencode.php
echo rawurlencode("http://abc.com/hi-1?source=google");
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.