Search
 
SCRIPT & CODE EXAMPLE
 

PHP

php server sent events

header('Content-Type: text/event-stream');
header('Cache-Control: no-cache');

while (true) {
  	$data = [
    	'name' => 'Rasmus Lerdorf'
    ]

  	echo "event: sse
";
  	echo "data: " . json_encode($data) . "

";
    echo str_pad('', 4096) . "
";
      
	ob_flush();
  	flush();
  	sleep(1);

  	if (connection_aborted()) {
    	break;
  	}
}
ob_end_flush();
Comment

PREVIOUS NEXT
Code Example
Php :: remove text keep numbers only php 
Php :: redirect woocommerce thank you 
Php :: laravel/ui for laravel 7 
Php :: word press get home page id 
Php :: create a modal livewire laravel 
Php :: base url laravel 
Php :: laravel where closure 
Php :: laravel collection reject 
Php :: no privileges to create databases phpmyadmin 
Php :: ajax get request in laravel 
Php :: File Reading Mode PHP 
Php :: globals in php 
Php :: laravel auth login with phone or email 
Php :: php oop 
Php :: php get url parameter 
Php :: Laravel Migration Error: Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes 
Php :: eloquent pluck multiple columns 
Php :: aapanel ubuntu 20.04 
Php :: wp_get_attachment alt text 
Php :: php get highest key in array 
Php :: return view in laravel controller 
Php :: artisan make command 
Php :: How to write a loop in PHP 
Php :: date to string php 
Php :: laravel checkbox checked 
Php :: pdo bind param 
Php :: filter validate email php 
Php :: carbon previous day 
Php :: how to join two tables in laravel 
Php :: wordpress php cpt get all taxonomy 
ADD CONTENT
Topic
Content
Source link
Name
4+4 =