1

Possible Duplicate:
PHP: Suppress output within a function?

I am using multiple php scripts.."

That include libraries I need. The thing is that they are designed to give an output to the browser in the forms of echo and print or print_r

However I need to use them and not display anything for all I care is the operation they do. Is there any way I can supress the output those functions give without modifying source code?

Community
  • 1
  • 1
quinestor
  • 1,432
  • 4
  • 19
  • 40

2 Answers2

4

You can use output buffering, and just discard the buffer:

ob_start();

function_that_prints_stuff_1();
function_that_prints_stuff_2();

// Done with the printing functions, discard the buffer:
ob_end_clean();
nickb
  • 59,313
  • 13
  • 108
  • 143
1

Use ob_start and ob_clean

//start of your script
ob_start();

/*some library stuff*/

// clean up the buffer
ob_end_clean();

/*your stuff*/
inhan
  • 7,394
  • 2
  • 24
  • 35
Louis Huppenbauer
  • 3,719
  • 1
  • 18
  • 24