我想要使用if语句来使用布尔值,它不起作用。顶部是我使用的函数,底部是if语句。当我将if语句更改为false时,我会得到结果,但我需要true和false布尔值。任何提示无法返回一个函数的布尔值在php
public function find($key) {
$this->find_helper($key, $this->root);
}
public function find_helper($key, $current){
while ($current){
if($current->data == $key){
echo " current";
return true;
}
else if ($key < $current->data){
$current= $current->leftChild;
//echo " left ";
}
else {
$current=$current->rightChild;
//echo " right ";
}
}
return false;
}
if($BST->find($randomNumber)){//how do I get this to return a true value?
echo " same ";
}
谢谢你这么多,我不能相信我错过了 – Aaron 2011-05-15 17:05:25
请注明答案的答案。 – hakre 2011-05-15 17:29:40