$val){ if(is_array($val)) continue; $key = trim($key); $val = trim($val); if(empty($key)) continue; $append .= "&{$key}={$val}"; } return "{$url[0]}?".substr($append, 1); } return $_SERVER["REQUEST_URI"]; } public static function delParams($params = array(), $withSymbol = false){ if($params){ $get = self::getParams(); $url = explode("?", $_SERVER["REQUEST_URI"], 2); $append = ""; foreach($params as $k){ if(Str::isBlank($k)) continue; if(isset($get[$k])) unset($get[$k]); } if($get){ foreach($get as $key => $val){ $append .= "&{$key}={$val}"; } } $url = $append ? "{$url[0]}?".substr($append, 1)."&" : "{$url[0]}?"; } else{ $url = self::getUrl().self::getSymbol(); } if(!$withSymbol) $url = substr($url, 0, -1); return $url; } public static function delParam($param){ return self::delParams(array($param)); } public static function clean(){ $get = self::getParams(); if($get){ $url = explode("?", $_SERVER["REQUEST_URI"], 2); $append = ""; $count = 0; foreach($get as $key => $val){ if(!is_string($val)) continue; if(trim($val) === "") $count++; else $append .= "&{$key}={$val}"; } $url = $append ? "{$url[0]}?".substr($append, 1) : $url[0]; if($count) header("location: {$url}"); } } public static function getPath(){ $url = explode("?", $_SERVER["REQUEST_URI"], 2); return $url[0]; } public static function getAppend(){ $append = ""; if($get = self::getParams()){ foreach($get as $key => $val){ if(is_array($val)) continue; $append .= "&{$key}={$val}"; } $append = "?".substr($append, 1); } return $append; } public static function getUrl(){ return self::getPath().self::getAppend(); } public static function getSymbol(){ return strpos($_SERVER["REQUEST_URI"], "?") === false ? "?" : "&"; } }