我想要使用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