0
在下面的If .. else語句中,我想看看是否第一,有一個第四個麪包屑(URI數組4),然後看看它是否是一個數字..PHP其他語句不工作,因爲它應該.. is_numeric和isset
但雙方始終返回true,數字,字母或空..
誰能告訴我爲什麼?
// checks the third breadcrumb contained within the breadcrumbs class to see
// if it is an article. Then uses a recursive function to search the first
// and second breadcrumbs to see if they exist within their respective menu
// arrays. finally, if that validates, then the fourth breadcrumb is checked
// to see if it exists (not empty) AND if it is a number.
else
if (($this->breadcrumbs->getCrumb(3)=='article' &&
$array_helper->recValueReturn($this->breadcrumbs->getCrumb(2),
$this->getNavTwo()) &&
$array_helper->recValueReturn($this->breadcrumbs->getCrumb(1),
$this->getNavOne())) || ($this->breadcrumbs->getCrumb(4)) &&
is_numeric($this->breadcrumbs->getCrumb(4))) {
...
總是以下驗證爲False:
else
if (($this->breadcrumbs->getCrumb(3)=='article'&&
$array_helper->recValueReturn($this->breadcrumbs->getCrumb(2),
$this->getNavTwo()) &&
$array_helper->recValueReturn($this->breadcrumbs->getCrumb(1),
$this->getNavOne())) &&
(array_key_exists($this->breadcrumbs->getCrumb(4),
$this->breadcrumbs->getCrumbs())&&
is_numeric($this->breadcrumbs->getCrumb(4)))) {
...
'$ this-> breadcrumbs-> getCrumb(3)'是什麼格式和數據? – Raptor
你有沒有嘗試輸出你正在檢查的各種值? – Jim
您是否嘗試過使用具有描述性名稱的函數對其進行重構,以便任何人都能知道發生了什麼,而不會盯着它幾分鐘? –