Re: Null Coalesce Operator and Undefined Indexes

From: Date: Mon, 27 Nov 2017 19:53:37 +0000
Subject: Re: Null Coalesce Operator and Undefined Indexes
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-326277@lists.php.net to get a copy of this message
On Sat, Nov 25, 2017 at 9:12 AM, Jennifer <jennifer@superiorshelving.com> wrote: > I'm using PHP 7.1 now and just changed some code to use the Null > Coalesce Operator, like so: > > $ua = sanitize($_SERVER['HTTP_USER_AGENT']) ?? null; > You must use the ?? operator on the array access before passing it to your sanitize() function. $ua = sanitize($_SERVER['HTTP_USER_AGENT'] ?? null); Cheers, David

« previous php.general (#326277) next »