2010-06-01 47 views
1

這就是我到目前爲止;如何在filter_input()上使用ReflectionFunction?

<?php ReflectionFunction::export(new ReflectionFunction(filter_input())); 

而且我得到這個錯誤: 警告:filter_input()預計至少2個參數,0在C中給出:\ WAMP \ WWW \ POS \通道4 \ inspect_filter_input_function.php第2行

如果我擺脫了括號,我得到了一個警告,但我函數的信息。如果我把兩個未定義的變量,它抱怨,我什麼也沒得到。我想知道如果我能得到一個例子如何用參數反映功能。

回答

2

ReflectionFunction ::出口()需要字符串(函數的名稱)作爲第一個參數,而不是一個ReflectionFunction對象:

ReflectionFunction::export('filter_input'); 
/* Output: 
Function [ <internal:filter> function filter_input ] { 
} 
*/ 

$ouput = ReflectionFunction::export('filter_input', true); 

一種替代是直接打印ReflectionFunction對象,因爲它實現了魔術方法__toString():

echo new ReflectionFunction('filter_input'); 
/* Output: 
Function [ <internal:filter> function filter_input ] { 
} 
*/ 
相關問題