Home >Backend Development >PHP Problem >How to determine whether there are parameters in php
How to determine whether there are parameters in php: first obtain the link through the "$_SERVER["REQUEST_URI"];" method; then determine whether there are parameters in the link through the if statement; and finally output the judgment result through echo.
Recommended: "PHP Video Tutorial"
Example: php determines whether the URL has parameters
$old_url = $_SERVER["REQUEST_URI"]; //检查链接中是否存在 ? $check = strpos($old_url, '?'); //如果存在 ? if($check !== false) { //如果 ? 后面没有参数,如 http://www.yitu.org/index.php? if(substr($old_url, $check+1) == '') { //可以直接加上附加参数 $new_url = $old_url; } //如果有参数,如:http://www.yitu.org/index.php?ID=12 else { $new_url = $old_url.'&'; } } //如果不存在 ? else { $new_url = $old_url.'?'; } echo $new_url;
The above is the detailed content of How to determine whether there are parameters in php. For more information, please follow other related articles on the PHP Chinese website!