This article mainly introduces PHP's implementation of the alert () Prompt box function similar to js, which is very practical. We recommend it to you here for your reference and hope you will like it. It is mainly used to add judgment prompts, jump, return, and refresh.
The Code is as follows:
/**
* JS prompt jump
* @ Param $ tip prompt message in the pop-up window (blank, no prompt)
* @ Param $ type the setting type is close = close, back = return, refresh = prompting for heavy load, jump prompting and jump to url
* @ Param $ url jump url
*/
Function alert ($ tip = "", $ type = "", $ url = ""){
$ Js = "script";
If ($ tip)
$ Js. = "alert ('". $ tip ."');";
Switch ($ type ){
Case "close": // close the page
$ Js. = "window. close ();";
Break;
Case "back": // return
$ Js. = "history. back (-1 );";
Break;
Case "refresh": // refresh
$ Js. = "parent. location. reload ();";
Break;
Case "top": // exit the framework
If ($ url)
$ Js. = "top. location. href = '". $ url ."';";
Break;
Case "jump": // jump
If ($ url)
$ Js. = "window. location. href = '". $ url ."';";
Break;
Default:
Break;
}
$ Js. = "script";
Echo $ js;
If ($ type ){
Exit ();
}
}
The above is all the content of this article. I hope it will help you learn php.