靜態(tài)工具類
本節(jié)教學(xué)是呼叫靜態(tài)工具類別的靜態(tài)方法完成彈窗跳轉(zhuǎn)功能
#1,封裝彈窗跳轉(zhuǎn)方法
建立工具類別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,工具類別的呼叫
在以後需要跳到其他頁(yè)面的時(shí)候直接呼叫Tool類別裡的skipPage()方法和returnPage()方法就行