Buy best selling Linux books

<< View More Computer Tips

Added On: 27/11/15   |    Category: PHP5    |    Number of Views: 1478

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']); ?>

Search Site

Search other tutorials and tips on My Computer Tips by entering your search terms below

Services

The Linux Foundation

Best selling Unix / Linux books
Nvidia Graphics Cards
Save 15% off .CO.UK domains at 123-Reg
Save 15% off .COM domains at 123-Reg
cPanel Hosting Plans
Xilo Web Hosting Plans