For example, paging, because some links already have parameters, the original parameters cannot be discarded when appending paging information, so determine whether the link has parameters, and then append paging information as needed.
The method is very simple:
Copy the code The code is as follows:
((strpos($url, '?') !== false) ? '&' : '?');
Copy the code The code is as follows:
$old_url = $_SERVER[" REQUEST_URI"];
//Check if the link exists?
$check = strpos($old_url, '?');
//If it exists?
if($check !== false)
{
//If? There are no parameters behind, such as http://www.yitu.org/index.php?
if(substr($old_url, $check+1) == '')
{
//You can add additional parameters directly
$ new_url = $old_url;
}
else //If there are parameters, such as: http://www.yitu.org/index.php?ID=12
{
$new_url = $old_url.'&';
}
}
else //If it does not exist?
{
$new_url = $old_url.'?';
}
echo $new_url;
?>
The above introduces the PHP code. Check whether the URL link already has PHP code with parameters. Add ? or &, which includes PHP code content. I hope it will be helpful to friends who are interested in PHP tutorials.