函数Php我有这样与参数0
public function get_page($position) {
switch ($position) {
case "current":
echo "current";
return $this->current_page;
break;
case "first":
echo "first";
return $this->current_page >= 3 ? 1 : false;
break;
case "last":
echo "last";
return $this->current_page <= $this->total_pages() - 2 ? ceil($this->count/$this->nb_items_to_show) : false;
break;
case "previous":
echo "previous";
return $this->current_page - 1 >= 1 ? $this->current_page - 1 : false;
break;
case "next":
echo "next";
return $this->current_page + 1 <= $this->total_pages() ? $this->current_page + 1 : false;
break;
case is_int($position):
echo "int";
if ($position >= 1 && $position <= $this->total_pages()) {
return $position;
} else {
return false;
}
break;
default:
echo "default";
return false;
break;
}
}
的功能。当我打电话的功能,它适用于所有的参数,除了0,然后进在开关“当前”的情况。
$paginator->get_page(0);
如果我打电话与报价功能为 “0”,它的工作原理。 但功能可以这样调用
$paginator->get_page($paginator->get_page("current") - 2);
我怎么能说与参数0的功能?
是'$ paginator-> get_page(0);'不等同于'$分页程序 - > get_page( '第一');'? – Dale
我认为某段代码丢失了......如果输入为0或“0”,switch语句应该为默认值 –
参数0如何变为“current”?它不应该默认?或可能is_int()? – kennypu