Encode to URL encoded format – PHP

URL-encoding, also known as “percent-encoding”, is a mechanism for encoding information in a Uniform Resource Identifier (URI). Although it is known as URL-encoding it is, in fact, used more generally within the main Uniform Resource Identifier (URI) set, which includes both Uniform Resource Locator (URL) and Uniform Resource Name (URN). As such it is also used in the preparation of data of the “application/x-www-form-urlencoded” media type, as is often employed in the submission of HTML form data in HTTP requests.

<?php
$string = "https://www.google.com/";
urlencode($string);
?>

Use this to create URL encoded string of a given string: