Answers for "Creating default object from empty value"

PHP
3

Creating default object from empty value

$res = new \stdClass();
$res->success = false;
Posted by: Guest on August-21-2020
-1

Creating default object from empty value

// This message has been E_STRICT for PHP <= 5.3. Since PHP 5.4, it was unluckilly changed to E_WARNING. Since E_WARNING messages are useful, you don't want to disable them completely.
// To get rid of this warning, you must use this code:

if (!isset($res)) 
    $res = new stdClass();

$res->success = false;

// this code is from @TMS' answer on the source
Posted by: Guest on January-05-2021

Code answers related to "Creating default object from empty value"

Browse Popular Code Answers by Language