The
PHP jump, that is, redirecting the browser to the specified URL, is a very common feature. This feature also has some detail requirements, such as how many seconds to wait for the jump, with no JavaScript implementation jump, and so on. The following jump methods take into account a lot of, and parameterized, can be used in specific projects.
<?php/** * Redirect browser to the specified URL * * @param string $url the URL to redirect * @param int $dela Y wait a few seconds to jump * @param bool $JS Indicates whether to return the JavaScript code for jumps * @param bool $jsWrapped Indicate whether to return JavaScript code when using &
Lt;mce:script type= "Text/javascript" ><!--label * @param bool $return Indicates whether the generated JavaScript code is returned.
function Redirect ($url, $delay = 0, $js = False, $jsWrapped = True, $return = False) {
$delay = (int) $delay;
if (! $js) {if (headers_sent () | | $delay > 0) {echo <<<eot
Compilation of a generic action hint class
See more highlights of this column: http://www.bianceng.cnhttp://www.bianceng.cn/webkf/PHP/
In the design of some systems, often need to give users the action prompts. This kind of hint is very important, the friendly hint can enhance the user to the system of favor degree. Operation tips have a lot of design, the following is a simple scheme of mine, only to stimulate.
<?php class tips{Private $tips;
static private $_instance; Private Function __construct ($string, $url) {$this->tips = "<meta Http-equiv=refresh content=4;u Rl= $url > <div style= ' border:1px solid #B4D8F4; width:320px; height:120px; margin:0 Auto; font-size:12px; ' > <div style= ' background-color: #CDE6F9; height:20px; ' ></div> <div align= ' center ' style= ' font-size:14px; Font-weight:bold; margin:20px 0 20px 0; ' > $string </div> <div align= ' center ' ><a href= ' $url ' > Return </a> (4 seconds to return automatically) </div> </div
> ";
return $this->tips;
The Public Function __tostring () {return $this->tips;
Private Function __clone () {} public static function Get_tips ($string, $url) { if (FALSE = = (self::$_instance instanceof self)) {SELf::$_instance = new self ($string, $url);
return self::$_instance; }}?>
This class feature is simple, that is, to achieve 4 seconds after the jump to a link, or click to jump to that link.
__tostring () This function is important, it can implement the string output of the class object.
How do you use this class?
Include_once ("./tips_class.php");
$hit = "Error: Two input passwords inconsistent";
$jump = ". /login.php ";
echo $tips = Tips::get_tips ($hit, $jump);