• PHP Video Tutorials

PHP - rawurlencode() Function



rawurlencode() function is a URL encode according to RFC 3986.

Syntax

string rawurlencode( string $str )

rawurlencode() function can encode a given string according to RFC 3986.

rawurlencode() function can return a string in which all non-alphanumeric characters except "-_.~" is replaced with percent (%) sign followed by two hex digits. This is an encoding described in RFC 3986 for protecting literal characters from being interpreted as special URL delimiters, and for protecting URLs from being mangled by transmission media with character conversions (like some email systems).

Example

<?php
   echo '<a href="ftp://user:', rawurlencode('foo @+%/'),
      '@ftp.example.com/x.txt">';
?>

Example

<?php
   echo '<a href="http://example.com/department_list_script/',
      rawurlencode('sales and marketing/Miami'), '">';
?>
php_function_reference.htm
Advertisements