我有这样的功能
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 调用函数?