0
我想弄清楚如何使用算法的輸出作爲findLarge的輸入。 算法產生,我想在findLarge上工作的陣列如何將一種方法的輸出用作另一種方法的輸入?
class CSVParser
{
public $output = NULL;
public $digits = NULL;
public $largest = NULL;
public function __construct($file)
{
if (!file_exists($file)) {
throw new Exception("$file does not exist");
}
$this->contents = file_get_contents($file);
$this->output = array();
$this->digits = array();
$this->largest = array();
}
public function algorithm() {....}
public function findLarge($a)
{
// just push it back so I know it's working
var_export($a); // is NULL
$this->largest = $a; // return NULL
}
}
$parser->algorithm();
$parser->findlarge($input); print_r($parser->largest);
爲什麼不能'$ parser-> findlarge($ parser-> algorithm());'? –