Today's Question:  What does your personal desk look like?        GIVE A SHOUT

SEARCH KEYWORD -- ob_start()



  PHP's Output Buffering

While profiling our application I came across a a rather strange memory usage by the ob_start() function. We do use ob_start() quite a bit to defer output of data, which is a common thing in many applications. What was unusual is that 16 calls to ob_start() up chewing through almost 700kb of memory, given that the data being buffered rarely exceeds 1-2kb, this was quite unusual. I started looking at the C code of the ob_start() function and found this interesting bit of code inside php_sta...

   PHP,Memory,ob_start(),source,40kB     2011-12-08 10:20:32

  PHP buffer: output_buffering and ob_start

buffer is one piece of memory section, it is usually 4Kb in Linux. It is mainly used between different devices with different speed or different priorities. With buffer, the waiting time between different processes will be reduced. Here is one simple example, when you type something in a text editor, every time when you type a character, the operating system will not write it to the disk directly, instead it will write it to buffer first When the buffer is full, the data in the buffer will be wr...

   PHP buffer,output_buffering,ob_start     2013-06-20 22:54:15

  Handle ”cannot modify header information – headers already sent by”

Man PHP developers should encounter ”Warning: Cannot modify header information – headers already sent by ….” error before when executing a PHP script. Here are some solutions to this error. 1. Blank line Check whether there is any blank line after , especially in the files which are used in include() and require(0, some problems are caused by blank lines. 2. Add exit() after head() header (“Location: xxx”); exit(); 3. Use output cache <?php ob_start(); ...

   header sent, PHP error handle     2012-11-17 08:45:22

  Output control functions in PHP

The Output Control functions in PHP allow you to control when output is sent from the script. This can be useful in several different situations, especially if you need to send headers to the browser after your script has began outputting data. The Output Control functions do not affect headers sent using header() or setcookie(), only functions such as echo and data between blocks of PHP code. These output control functions include ob_start(0, ob_clean(),ob_get_contents(), etc. To be honest, I a...

   PHP,output buffer,relationship,ob     2012-06-15 10:11:58

  40+ Techniques to enhance your php code

1. Do not use relative paths , instead define a ROOT path Its quite common to see such lines : 1require_once('../../lib/some_class.php'); This approach has many drawbacks : It first searches for directories specified in the include paths of php , then looks from the current directory. So many directories are checked. When a script is included by another script in a different directory , its base directory changes to that of the including script. Another issue , is that when a script is being ru...

   PHP,Quirk,Trick,Efficiency,Techniques     2012-04-10 13:06:55