封装一个框架内部使用的alert

版权声明: https://blog.csdn.net/gwz1196281550/article/details/80810822
static function showMsg($pMsg, $pUrl = false,$perant=""){
   is_array($pMsg) && $pMsg = join('\n', $pMsg);
   echo '<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />';
   if('.' == $pUrl) $pUrl = $_SERVER['REDIRECT_URL'];
   if($perant=="perant"){$perant=$perant.".";}else{
      $perant="";
   };
   echo '<script type="text/javascript">';
   if($pMsg) echo "alert("$pMsg");";
   if($pUrl) echo $perant."self.location='{$pUrl}'";
   elseif(empty($_SERVER['HTTP_REFERER'])) echo 'window.history.back(-1);';
   else echo $perant."self.location='{$_SERVER['HTTP_REFERER']}';";
   exit('</script>');
}

猜你喜欢

转载自blog.csdn.net/gwz1196281550/article/details/80810822