2013-01-23 33 views
1

可能重複:
PHP: Suppress output within a function?如何抑制功能的回聲?

我使用多個PHP腳本..」

包括我需要的庫的事情是,他們的目的是給一個輸出到瀏覽器中的echoprintprint_r

形式

但是我需要使用它們,而不是顯示任何東西,我關心的是他們所做的操作。有什麼辦法可以抑制這些函數的輸出而不修改源代碼?

+0

您可以從客戶端是什麼意思? – hjpotter92

+0

@BackinaFlash nope,服務器端。我正在調用函數 – quinestor

回答

1

使用ob_startob_clean

//start of your script 
ob_start(); 

/*some library stuff*/ 

// clean up the buffer 
ob_end_clean(); 

/*your stuff*/ 
+0

'ob_end_clean' not clean_end;) –

+0

whoupps ...已更正;) –

4

您可以使用output buffering,只是丟棄緩衝:

ob_start(); 

function_that_prints_stuff_1(); 
function_that_prints_stuff_2(); 

// Done with the printing functions, discard the buffer: 
ob_end_clean();