<?php
$canonical = "https://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
echo '<link rel="canonical" href="'.$canonical.'">';
?>
<?php
$canonical = "https://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
$noParamsCanonical = strtok($canonical, '?');
echo '<link rel="canonical" href="'.$noParamsCanonical.'">';
?>