未简化的代码:
if (isset($_GET['page'])) {
$_page = $_GET['page'];
if (empty($_page) || $_page < 0 || !is_numeric($_page)) {
$_page = 1;
} else {
$_page = intval($_page);
}
} else {
$_page = 1;
}
稍微简化的代码:
$_page = $_GET['page'] ? $_GET['page'] : 1;
if($_page <=0 || !is_numeric($_page)){
$_page = 1;
}else{
$_page = intval($_page);
}
最后简化的代码:
$_page = $_GET['page']>0 ? intval($_GET['page']) : 1;