Thursday, December 11, 2025
HomeUncategorisedPHP | urlencode() Function

PHP | urlencode() Function

The urlencode() function is an inbuilt function in PHP which is used to encode the url. This function returns a string which consist all non-alphanumeric characters except -_. and replace 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:

Program 1:




<?php
  
// PHP program to illustrate urlencode function
echo urlencode("https://geeksforgeeks.org/") . "\n";
  
?>


Output:

https%3A%2F%2Fneveropen.tech%2F

Program 2 :




<?php
  
// PHP program to illustrate urlencode function
echo urlencode("https://ide.geeksforgeeks.org/") . "\n";
echo urlencode("https://write.geeksforgeeks.org/") . "\n";
echo urlencode("https://practice.geeksforgeeks.org/") . "\n";
echo urlencode("https://geeksforgeeks.org/") . "\n";
  
?>


Output:

https%3A%2F%2Fide.geeksforgeeks.org%2F
https%3A%2F%2Fwrite.geeksforgeeks.org%2F
https%3A%2F%2Fpractice.geeksforgeeks.org%2F
https%3A%2F%2Fneveropen.tech%2F

Reference: http://php.net/manual/en/function.urlencode.php

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.

RELATED ARTICLES

Most Popular

Dominic
32440 POSTS0 COMMENTS
Milvus
105 POSTS0 COMMENTS
Nango Kala
6811 POSTS0 COMMENTS
Nicole Veronica
11950 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12023 POSTS0 COMMENTS
Shaida Kate Naidoo
6943 POSTS0 COMMENTS
Ted Musemwa
7193 POSTS0 COMMENTS
Thapelo Manthata
6889 POSTS0 COMMENTS
Umr Jansen
6880 POSTS0 COMMENTS