The URL function for parsing the in-band characters in PHP is shared,
Many times, when writing a Web application, you will encounter Chinese and other character conflicts, such as the URL link contains the text character, then the use of wget/curl/file_get_contents and so on to get information when it will directly hit a big "404", will be very silent.
Here is a small function to solve this problem, just limited in path to parse it, related to the function of the use of people can view the manual on the line.
Copy the Code code as follows:
function Urlconvert ($url) {
$PATHARR = Array ();
$modules = Parse_url ($url);
$path = $modules [' path '];
$pathSplit = explode ('/', $path);
foreach ($pathSplit as $row) {
$PATHARR [] = Rawurlencode ($row);
}
$urlNew = $modules [' scheme ']. ":/ /". $modules [' Host '].implode ('/', $PATHARR);
return $urlNew;
}
http://www.bkjia.com/PHPjc/945717.html www.bkjia.com true http://www.bkjia.com/PHPjc/945717.html techarticle PHP in the parsing of the URL function with Chinese characters to share, many times, when writing Web applications, will encounter Chinese and other character conflicts, for example, some URL links contain Chinese ...