Just for completeness, another way to achieve it is to pull operator rank:
$page = (int)$_GET["page"] or $page = 1;
Many people perceive this as unreadable however, though it's shorter than isset() constructs.
Or if you are using input objects or any other utility class:
$page = $_GET->int->default("page", 1);
No comments:
Post a Comment