Re: pipes, scalar objects and on?
| From: | Craig Francis | Date: | Tue, 18 Jul 2023 15:57:50 +0000 |
| Subject: | Re: pipes, scalar objects and on? | ||
| References: | 1 2 3 4 5 6 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-120838@lists.php.net to get a copy of this message | ||
On 18 Jul 2023, at 16:13, Larry Garfield <larry@garfieldtech.com> wrote:
> PHP at the moment leans heavily on the "null is error and build tooling around that"
> approach
Yep, you should never use NULL in your code, the following is catastrophically bad...
$search = ($_GET['q'] ?? NULL);
$search = (isset($_GET['q']) ? $_GET['q'] : NULL); // Pre PHP 7
$search = filter_input(INPUT_GET, 'q');
$search = $request->input('q'); // Laravel
$search = $request->get('q'); // Symfony
$search = $this->request->getQuery('q'); // CakePHP
$search = $request->getGet('q'); // CodeIgniter
$search = json_decode('{"q":null}');
And all fields in the database must be set to NOT NULL, never use things like LEFT JOIN, etc... :-(
Craig