php中检查 url 链接是否已经有参数,添加 ? 或 &代码
栏目:php教程时间:2014-01-17 06:14:27
- <?php
- $old_url = $_SERVER["REQUEST_URI"];
-
-
- $check = strpos($old_url, '?');
-
-
- if($check !== false)
- {
-
- if(substr($old_url, $check+1) == '')
- {
-
- $new_url = $old_url;
- }
- else
- {
- $new_url = $old_url.'&';
- }
- }
- else
- {
- $new_url = $old_url.'?';
- }
-
- echo $new_url;
- ?>
------分隔线----------------------------
------分隔线----------------------------