从类中获取函数结果


Get the function result from a class

我在一个类中有一个函数,我想得到这个函数的结果,比如:

返回的危险功能有:dl、系统

这是我的代码

public final function filterFile(){
$disabled_functions = ini_get('disable_functions');
$disFunctionsNoSpace = str_replace(' ', '', $disabled_functions);
$disFunctions = explode(',', $disFunctionsNoSpace);
$this->disFunctions = $disFunctions;
// get file content of the uploaded file (renamed NOT the temporary)
$cFile = file_get_contents($this->fileDestination, FILE_USE_INCLUDE_PATH);

$found = array();
foreach($this->disFunctions as $kkeys => $vvals)
{            
    if(preg_match('#'.$vvals.'#i', $cFile))
    {                  
        array_push($found, $vvals);
    } 
} // end foreach
} // end filterFile
// calling the class
$up = new uploadFiles($filename);
$fileterringFile    = $up->filterFile();
print_r($fileterringFile);
var_dump($fileterringFile);

编辑:添加2个错误功能:

// check if any uErrors
public final function checkErrors(){
    $countuErrors = count($this->uErrors);
    if((IsSet($this->uErrors) && (is_array($this->uErrors) && ($countuErrors > 0))))
    {
        return true;            
    }
        return false;
} // end checkErrors()

// print user errors
public final function printErrors(){
    $countuErrors = count($this->uErrors);
    if((IsSet($this->uErrors) && (is_array($this->uErrors) && ($countuErrors > 0))))
    {
        echo '<ul>';
        foreach($this->uErrors as $uV)
        {       
            echo '<li>';
            echo $uV;
            echo '</li>';
        }
        echo '</ul>';
    }                
} // end printErrors()

提前感谢

在结束filterFile的末尾,添加:

return 'Returned dangerous functions are: '.implode(',',$found);