iMohammadreza iMohammadreza - 3 months ago 6x
PHP Question

How to set optional get in php

In a php file named show.php I used GET method to receive datas.

In newer version of my app, I have another GET method for offset. And that's an optional data.

How can I optimise php file for working with and without get methods. In another meaning, How to set optional GET method?


Use a default value and a ternary condition?:

$limit = isset($_GET['limit']) ? $_GET['limit'] : 1;
$offset = isset($_GET['offset']) ? $_GET['offset'] : 1;