How I PHP: Using defaults for input arguments
Just a short one today, because I’m really busy (un)fortunately.
You can take out and check each argument at a time:
$search = isset($_GET['search']) ? $_GET['search'] : null; $page = isset($_GET['page']) ? $_GET['page'] : 1; $limit = isset($_GET['limit']) ? $_GET['limit'] : 15; // etc
But to do it in one go, just do:
$args = $_GET + array('search'=>null, 'page'=>1, 'limit'=>15);
Note that in some cases it is important to filter your input, that is not done here.
30 Jun 2008 Arnold Daniels 6 comments




