ZendCon 07 – Day 2
Second day here at the ZendCon 07, and no session better than Eli White’s PHP Features You Didn’t Know Existed to start off the day. PHP developers who’ve been coding for a number of years (some 10 years or more) were scoffing at the idea that Eli would present anything new or ‘undiscovered’. But there wasn’t a cough in the packed room as Eli presented rarely-used hidden gems in the PHP language. The applause at the end surely put any scoffism to rest.
I can’t list all the neat stuff that Eli covered, but something that caught my attention was the topic of closing connections early. I’ve been trying to find an elegant way to solve this problem for a personal project and this might just be the way to do it. Here’s some rough code (more specific code examples to come later):
ignore_user_abort(true);
header("Connection: close");
header("Content-Length: ", mb_strlen($response));
echo $response;
flush();
The ignore_user_abort(true) function basically lets your script continue execution even though the user might have hit the STOP button in his browser, or the connection between the user and your script got disconnected, etc. This neat code above lets you return a quick response (great for Ajax button clicks) so that you can update client side – keeping your site fast and responsive – while your script chugs along server side.
More updates coming up today, but don’t forget to come to the PHP Nightclub event (starts at 8pm) and check out the Yahoo! gang. Btw, the event is open to all, so there’s no excuse to miss it!
PrasSarkar.com
No Comments, Comment or Ping
Reply to “ZendCon 07 – Day 2”