Category: PHP5

Added: 27th of November 2015

Viewed: 2955 times

Pass ampersand through query strings in URL using PHP5

If you ever need to pass an ampersand through a query string in your URL and echo the result at the other end using PHP, you need to use the urlencode and urldecode function in your scripts.

If you don't add the urlencode or urldecode function then only the first part of the variable will be sent and anything after the & will be removed from the result.

<!-- page1.php -->
<a href="order.php?dish=<?php echo urlencode('Fish & Chips'); ?>">Fish & Chips</a>

<!-- page2.php -->
You ordered: <?php echo urldecode($_GET['dish']); ?>

Other Tips & Tutorials


Convert all characters to Upper or Lower case in PHP5

Posted: 7th of October 2020

Views: 628


Get the day of the week for a specified date using PHP5

Posted: 17th of January 2016

Views: 2272


How to upload files larger than 2MB using PHP5

Posted: 14th of January 2016

Views: 2426


Preserve line breaks in PHP. nl2br function

Posted: 21st of December 2015

Views: 5427


Convert a Unix timestamp to date and time using PHP

Posted: 18th of December 2015

Views: 2596


How to validate a form using PHP5

Posted: 15th of December 2015

Views: 1504


Count the number of elements in a PHP array using the count() function

Posted: 15th of December 2015

Views: 1402


Pass ampersand through query strings in URL using PHP5

Posted: 27th of November 2015

Views: 2955