PHP 自定义 alert 跳转方法

    /**
     * 跳转方法
     * @param $msg
     * @param null $path
     * @param null $parent
     */
    public function alert($msg,$path=NULL,$parent=NULL){
        if($parent === true){
            $str=<<<str
        <script>alert('{$msg}');parent.location.href='{$path}'</script>
str;
        }else if(empty($path)){
            $str=<<<str
        <script>alert('{$msg}');history.back()</script>
str;
        }else{
            $str=<<<str
        <script>alert('{$msg}');location.href='{$path}'</script>
str;
        };
        echo $str;
    }

 

posted @ 2018-05-16 13:45  宁佳兵  阅读(1160)  评论(0编辑  收藏  举报