note 127200 deleted from function.isset by cmb

From: Date: Mon, 27 Jun 2022 16:24:54 +0000
Subject: note 127200 deleted from function.isset by cmb
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-218625@lists.php.net to get a copy of this message
Note Submitter: Tim Furry ---- I kept having problems with a nested object always returning false when using isset() to check various levels. I assume this was due to some of the levels having values but not being variables. At any given time the subobjects might or might not have been set with values, but I needed to check if they did before doing further processing. Sample nested object: $sale->vehicle->model->year Doing a var_dump() at any of these levels (i.e. var_dump($sale->vehicle->model) would display a value, if the object was populated. isset($sale->vehicle->model) would always return a false on subobjects. My solution is: if (($sale->vehicle->model->year) ? (true) ? (false)) { //do some processing here because we found it } This seems to get around the isset() restriction that requires the operand to be a variable.

« previous php.notes (#218625) next »