靜態(tài)工具類
本節(jié)教程是調(diào)用靜態(tài)工具類的靜態(tài)方法完成彈窗跳轉(zhuǎn)功能
1,封裝彈窗跳轉(zhuǎn)方法
創(chuàng)建工具類Tool.class.php
代碼如下:
<?php /** * Created by PhpStorm. * User: Administrator * Date: 2018/3/3 0003 * Time: 下午 1:56 */ class Tool{ //執(zhí)行某個(gè)方法成功并需要跳轉(zhuǎn)到指定頁(yè)面時(shí)使用 public static function skipPage($info,$url){ echo "<script>alert('$info');location.href='$url';</script>"; exit(); } //某個(gè)操作執(zhí)行失敗時(shí)調(diào)用 public static function returnPage($info){ echo "<script>alert('$info');history.back();</script>"; } }
2,工具類的調(diào)用
在以后需要跳轉(zhuǎn)到其他頁(yè)面的時(shí)候直接調(diào)用Tool類里的skipPage()方法和returnPage()方法就行