I would like to display content only if the url contains certain parameter. In the case is checked whether the URL exists, for example, the parameter ?offset=10. If the parameter exists (site.com/post-name?offset=10) is shown the content X, otherwise the content is shown Y.
Eg:
function parameterUrl() {
$str = "?offset=10";
$uri = $_SERVER['REQUEST_URI'];
if ($uri == "http://site.com/post-name$str") {
echo "Show this";
}
else {
}
}
But the above function is not working. Can anyone help. Any idea is welcome. Thank you.
Your parameters are stored in the
$_GETglobals array.You need:
Update from Comment
If you are going to have multiple quantities then a switch statement would be better: