Forum Moderators: coopster
http://www.example.com/index.php?foo=1&bar=2
<?php
print_r($_GET);
?>
http://www.example.com/test.php?var=Manufacturer--First%26Second Array ( [var] => Manufacturer--First&Second ) urlencode()the parameter
htmlentities()the result
$param1='<some text>';
$param2='<some more text>';
$sep='&';
$url='http://example.com/test.php';
$param1=htmlentities( urlencode( $param1 ));
$param2=htmlentities( urlencode( $param2 ));
$url="$url?var=$param1$sep$param2";
index.php?q=foo&bar=pizza
<?php
header("content-type:text/html");
if (isset($_GET['amp;oops'])) {
echo "<p>Entity in the address bar is " . $_GET['amp;oops'] . "</p>
<p>Now let's do it right:
<a href=\"entity.php?test=1&oops=Entity-itis\">Click me</a>.</p>";
}
else if (isset($_GET['oops'])) {
echo "<p>Got it, <strong>no</strong> entity in the address bar is " . $_GET['oops'] . "</p>";
}
else {
echo "<p>To validate your code, apply htmlentities to text.
In the following link, the query string is
entity.php?test=1&amp;oops=Entity-itis - watch the
address bar to see what it does by
<a href=\"entity.php?test=1&amp;oops=Entity-itis\">Clicking this link</a></p>";
}
?>