note 50401 added to function.echo

From: Date: Sun, 27 Feb 2005 08:56:24 +0000
Subject: note 50401 added to function.echo
Groups: php.notes 
Request: Send a blank email to php-notes+get-85623@lists.php.net to get a copy of this message
Due to the way TCP/IP packets are buffered, using echo to send large strings to the client may cause a severe performance hit. Sometimes it can add as much as an entire second to the processing time of the script. This even happens when output buffering is used. If you need to echo a large string, break it into smaller chunks first and then echo each chunk. The following function will do the trick in PHP5: <?php function echobig($string, $bufferSize = 8192) { $splitString = str_split($string, $bufferSize); foreach($splitString as $chunk) echo $chunk; } ?> ---- Manual Page -- http://www.php.net/manual/en/function.echo.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+50401 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+50401&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+50401&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+50401&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+50401&report=yes&reason=useless Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+50401&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+50401&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#85623) next »