$original_string = "Hello World!"; $url_encoded_string = urlencode($original_string); echo $url_encoded_string; // Output: Hello+World%21
$name = "John Doe"; $age = 30; echo "My name is " . urlencode($name) . " and I am " . urlencode($age) . " years old."; // Output: My+name+is+John+Doe+and+I+am+30+years+old.Package Library: This function is part of the PHP core language, so no package library is needed.