Home / PHP Tips Generated By ChatGPT / Encoding and Decoding URL Strings in PHP Use urlencode() and urldecode() to encode and decode URL strings. Source Code $encoded = urlencode("This is a test!"); echo $encoded; // Outputs: This+is+a+test%21 echo urldecode($encoded); // Outputs: This is a test!