php return loading message

Solutions on MaxInterview for php return loading message by the best coders in the world

showing results for - "php return loading message"
Avia
02 Jan 2017
1<?php
2// Disable buffering
3@apache_setenv('no-gzip', 1);
4@ini_set('zlib.output_compression', 0);
5@ini_set('output_buffering', 'Off');
6@ini_set('implicit_flush', 1);
7// Flush buffers
8ob_implicit_flush(1);
9for ($i = 0, $level = ob_get_level(); $i < $level; $i++) ob_end_flush();
10?><!DOCTYPE html>
11<html>
12<head>
13  <title>Loading</title>
14</head>
15<body>
16  <div id="loading">LOADING</div>
17<?php
18// We need to send enough junk messages to make it works for all browsers
19echo str_repeat(" ", 1024), "\n";
20
21ob_start();
22// Long process starts here
23// For this example, just sleep for 5 seconds
24sleep(5); 
25echo "Loaded";
26// Flush output like this
27ob_flush();
28flush();
29?>
30</body>
31</html>
32