Home > Backend Development > PHP Tutorial > URL encoding processing in php

URL encoding processing in php

WBOY
Release: 2016-07-25 09:03:07
Original
1628 people have browsed it
  1. //Visit ftp://bbs.it-home.org/my documents/php tutorial.doc
  2. echo 'jbxue's directory"';
  3. ?>
Copy code

Due to historical reasons, in the early URL encoding regulations, spaces were converted to "+". If you want to be compatible with this encoding rule, you can use the urlencode() function. For example, the following example:

  1. //urlencode() encoding
  2. echo 'test';
  3. ?>
Copy code

Next we will talk about, since it can be encoded, of course it can also be decoded. The decoding functions corresponding to the two url encoding functions above are: rawurldecode() and urldecode(), such as those used in the following example:

  1. $a = explode('&', $QUERY_STRING);
  2. $i = 0;
  3. while ($i < count($a))
  4. {
  5. $b = split('=', $a[$i]);
  6. echo "Value for Parameter ", htmlspecialchars(urldecode($b[0])),' is ', htmlspecialchars(urldecode($b[1])) , "
    n";
  7. $i++;
  8. }
  9. ?>
Copy code


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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template