URL parameters obtained from the global variable $_GET
, which is actually an array. So, to find out if the URL contains a parameter, you can use the isset()
function.
if (isset($_GET['yourparametername'])) {
After the settings, you can create a separate array of such a parameter, which must be attached to the URL. LIKE
if(isset($_GET['param1'])) { \\The parameter you need is present $attachList['param1'] = $_GET['param1']; } if(isset($_GET['param2'])) { $attachList['param2'] = $_GET['param2]; }
Now, to find out if you need a symbol ?
just count this array
if(count($attachList)) { $link .= "?";
Update:
To find out if a parameter is set, just count $_GET
if(count($_GET)) {
source share