1
0
Fork 0
php-coding/14.work2.fun.php

50 lines
1.3 KiB
PHP

<?php
class ProcessMsg
{
/**
* @param $msg
* @return void
*/
public function simpleMsg($msg): void
{
echo $msg;
}
/**
* @param $msg
* @param $url
* @return void
*/
public function jumpMsg($msg, $url = null): void
{
if ($url == null) {
echo '<script>alert("' . $msg . '");location.reload()</script>';
} else {
echo '<script>alert("' . $msg . '");location.href="' . $url . '"</script>';
}
}
/**
* @param $msg
* @param $time
* @param $url
* @return void
*/
public function jumpMsgPending($msg, $time, $url = null): void
{
if ($url == null) {
$hr = $_SERVER['HTTP_REFERER'];
echo $msg . '<br>';
echo '页面将于' . $time . '秒后跳转。如果没有跳转,请点击这里<a href="' . $hr . '">返回</a>';
echo '<meta http-equiv="refresh" content="' . $time . ';url=' . $hr . '"/>';
} else {
echo $msg . '<br>';
echo '页面将于' . $time . '秒后跳转。如果没有跳转,请点击这里<a href="' . $url . '">返回</a>';
echo '<meta http-equiv="Refresh" content="' . $time . ';url=' . $url . '">';
}
}
}
$pm = new ProcessMsg();