PHP urlencode() Function Last Updated : 03 May, 2025 Comments Improve Suggest changes Like Article Like Report The urlencode() function is an inbuilt PHP function used to encode the URL. This function returns a string consisting of all non-alphanumeric characters except—_. It is replaced by the percent (%) sign, followed by two hex digits and spaces encoded as plus (+) signs. Syntax:string urlencode( $input )Parameters: This function accepts single parameter $input which is used to hold the url to be encoded. Return Value: This function returns an encoded string on success. Below programs illustrate the urlencode() function in PHP: Example 1: This example shows the implementation of PHP urlencode() Function. php <?php // PHP program to illustrate urlencode function echo urlencode("https://geeksforgeeks.org/") . "\n"; ?> Outputhttps%3A%2F%2F2.zoppoz.workers.dev%3A443%2Fhttps%2Fgeeksforgeeks.org%2F Example 2: This example shows the implementation of PHP urlencode() Function. php <?php // PHP program to illustrate urlencode function echo urlencode("https://write.geeksforgeeks.org/") . "\n"; echo urlencode("https://practice.geeksforgeeks.org/") . "\n"; echo urlencode("https://geeksforgeeks.org/") . "\n"; ?> Outputhttps%3A%2F%2F2.zoppoz.workers.dev%3A443%2Fhttps%2Fwrite.geeksforgeeks.org%2F https%3A%2F%2F2.zoppoz.workers.dev%3A443%2Fhttps%2Fpractice.geeksforgeeks.org%2F https%3A%2F%2F2.zoppoz.workers.dev%3A443%2Fhttps%2Fgeeksforgeeks.org%2F PHP is a server-side scripting language designed specifically for web development. You can learn PHP from the ground up by following this PHP Tutorial and PHP Examples. Comment More infoAdvertise with us Next Article PHP urlencode() Function R R_Raj Follow Improve Article Tags : Web Technologies PHP PHP-function Similar Reads PHP | urldecode() Function The urldecode() function is an inbuilt function in PHP which is used to decode url that is encoded by the encode () function. Syntax:string urldecode( $input )Parameters: This function accepts a single parameter $input which holds the url to be decoded. Return Value: This function returns the decode 1 min read PHP | rawurlencode() function The rawurlencode() function is an inbuilt function in PHP which is used to encode the URL(Uniform Resource Locator) according to RFC(Uniform Resource Identifier) 3986. Syntax: string rawurlencode( $str ) Parameters: This function accepts single parameters $str which is mandatory. It is used to store 1 min read PHP | rawurldecode() function The rawurldecode() function is an inbuilt function in PHP which is used to decode the encoded string. This function returns the decoded URL (original URL string) as a string. This function replaces the % sign followed by two hex value with literal characters. Syntax: string rawurldecode( $str ) Para 1 min read PHP strlen() Function The strlen() is a built-in function in PHP which returns the length of a given string.It calculates the length of the string including all the whitespaces and special characters. Syntax:strlen($string);Parameters: This parameter represents the string whose length is needed to be returned. Return Val 1 min read PHP mb_strlen() Function The mb_strlen() is an inbuilt PHP function that returns the string length in an integer. Syntax: mb_strlen($string, $encoding ): intParameters: This function accepts 2 parameters that are described below: $string: The string parameter whose lengths need to be determined. It is a required parameter.$ 1 min read Like