Wednesday, July 3, 2024
HomeLanguagesPhpPHP | 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://neveropen.co.za/") . "\n";
  
?>


Output:

https%3A%2F%2Fneveropen.co.za%2F

Program 2 :




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


Output:

https%3A%2F%2Fide.neveropen.co.za%2F
https%3A%2F%2Fwrite.neveropen.co.za%2F
https%3A%2F%2Fpractice.neveropen.co.za%2F
https%3A%2F%2Fneveropen.co.za%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.

Nicole Veronica Rubhabha
Nicole Veronica Rubhabha
A highly competent and organized individual DotNet developer with a track record of architecting and developing web client-server applications. Recognized as a personable, dedicated performer who demonstrates innovation, communication, and teamwork to ensure quality and timely project completion. Expertise in C#, ASP.Net, MVC, LINQ, EF 6, Web Services, SQL Server, MySql, Web development,
RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments