search
Homephp教程php手册PHP 实现类似js中alert() 提示框

这篇文章主要介绍了PHP 实现类似js中alert() 提示框功能,非常的实用,这里推荐给大家,有需要的小伙伴来参考下,希望大家能喜欢。

主要应用于添加判断提示,跳转,,返回,刷新。

复制代码 代码如下:


/**
 * JS提示跳转
 * @param  $tip  弹窗口提示信息(为空没有提示)
 * @param  $type 设置类型 close = 关闭 ,back=返回 ,refresh=提示重载,jump提示并跳转url
 * @param  $url  跳转url
 */
function alert($tip = "", $type = "", $url = "") {
    $js = "<script>";<br /> if ($tip)<br /> $js .= "alert('" . $tip . "');";<br /> switch ($type) {<br /> case "close" : //关闭页面<br /> $js .= "window.close();";<br /> break;<br /> case "back" : //返回<br /> $js .= "history.back(-1);";<br /> break;<br /> case "refresh" : //刷新<br /> $js .= "parent.location.reload();";<br /> break;<br /> case "top" : //框架退出<br /> if ($url)<br /> $js .= "top.location.href='" . $url . "';";<br /> break;<br /> case "jump" : //跳转<br /> if ($url)<br /> $js .= "window.location.href='" . $url . "';";<br /> break;<br /> default :<br /> break;<br /> }<br /> $js .= "</script>";
    echo $js;
    if ($type) {
        exit();
    }
}

以上所述就是本文的全部内容了,希望对大家学习php能有所帮助。

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!

Safe Exam Browser

Safe Exam Browser

Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.