PHP implementation of general alert functions _ PHP Tutorial

Source: Internet
Author: User
PHP implements General alert functions. PHP: how to implement general alert functions this article mainly introduces PHP's method for implementing general alert functions. The example shows how to implement prompt information for php custom alert functions, very practical PHP method for implementing general alert functions

This article mainly introduces the PHP method for implementing general alert functions. The example analyzes the tips of php custom alert functions for implementing prompt information, which is very useful. For more information, see

This example describes how to implement a common alert function in PHP. Share it with you for your reference. The details are as follows:

Function: common prompt
Parameter: prompt message, type or website, window name or function name, delay in milliseconds
Alert ("", "function", "close2", 300 );

The code is as follows:

?

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

Function Alert ($ Str, $ Typ = "back", $ TopWindow = "", $ Tim = 100 ){

Echo "script". chr (10 );

If (! Empty ($ Str )){

Echo "alert (\" Warning: \ n {$ Str} \ n \ ");". chr (10 );

}

Echo "function _ r_r _(){";

$ WinName = (! Empty ($ TopWindow ))? "Top": "self ";

Switch (StrToLower ($ Typ )){

Case "#":

Break;

Case "back ":

Echo $ WinName. ". history. go (-1);". chr (10 );

Break;

Case "reload ":

Echo $ WinName. ". window. location. reload ();". chr (10 );

Break;

Case "close ":

Echo "window. opener = null; window. close ();". chr (10 );

Break;

Case "function ":

Echo "var _ T = new function ('return {$ TopWindow} ') (); _ T ();". chr (10 );

Break;

// Die ();

Default:

If ($ Typ! = ""){

// Echo "window. {$ WinName}. location. href = '{$ Typ }';";

Echo "window. {$ WinName}. location = ('{$ Typ }');";

}

}

Echo "}". chr (10 );

// To prevent Firefox from refreshing the setTimeout

Echo "if (setTimeout (\" _ r_r _ () \ ",". $ Tim. ") = 2) {_ r_r _();}";

If ($ Tim = 100 ){

Echo "_ r_r _ ();". chr (10 );

} Else {

Echo "setTimeout (\" _ r_r _ () \ ",". $ Tim. ");". chr (10 );

}

Echo "script". chr (10 );

Exit ();

}

I hope this article will help you with php programming.

This article describes how to implement the common alert function in PHP. The example analyzes the tips for implementing the php custom alert function, which is very practical...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.