On 13 Dec 2022, at 12:39, Rowan Tommins <[email protected]> wrote:
> On 13/12/2022 10:11, Craig Francis wrote:
>> The null value can come from many sources (e.g. GET/POST/COOKIE/databases)
>
>
> These two examples are interesting in conjunction: $_GET, $_POST, and
> $_COOKIE will never contain null values unless you have code writing directly
> to them, because HTTP has no representation for it, only empty strings.
Most frameworks return NULL when the user has not provided the value:
$search = $request->input('q'); // Laravel
$search = $request->get('q'); // Symfony
$search = $this->request->getQuery('q'); // CakePHP
$search = $request->getGet('q'); // CodeIgniter
This is also common, to avoid undefined indexes (as you suggested earlier):
$search = ($_GET['q'] ?? NULL);
And some developers use:
$search = filter_input(INPUT_GET, 'q');
That said, I'm glad you have found a positive example from this change.
Craig
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: https://www.php.net/unsub.php