Test.php
697 字节
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<?php
namespace Controller;
use Lib\Mail\MailFun;
use Model\emailSql;
use Model\listsSql;
/**
 * @author:dc
 * @time 2023/2/13 11:28
 * Class Home
 * @package Controller
 */
class Test {
    public function home(){
        ob_start();
        header("Content-Type:text/event-stream;Charset=UTF-8;\n\n");
        header("cache-control:no-cache;\n\n");
        foreach (range(1,10) as $i)
        {
            echo $i.'hello world'.PHP_EOL.PHP_EOL ;
            ob_flush();
            flush();
            sleep(1);
        }
        ob_clean();
    }
    public function a(){
        header("Content-Type:text/html;Charset=UTF-8;");
        echo '1';
    }
}