PHP Tutorial - PHP rawurlencode() Function






Definition

The rawurlencode() function converts non-alphabetic symbols into numerical equivalents with a percent sign, such as %28 for "(".

Syntax

PHP rawurlencode() Function has the following syntax.

string rawurlencode ( string str )

Parameter

str is the string value to convert.

Return

PHP rawurlencode() Function returns the encoded string for URL.

Note

You can reverse this conversion using the rawurldecode() function.

Example

This is most commonly used for passing data over URLs.


<?PHP
$name = 'PHP from java2s.com'; 
$safe_name = rawurlencode($name); 
print $safe_name;
?>

The code above generates the following result.