Creating default object from empty value 1

Creating default object from empty value

$res = new \stdClass();
$res->success = false;

Here is what the above code is Doing:
1. It’s creating a new PHP object called $res.
2. It’s setting the success property of $res to false.
3. It’s setting the message property of $res to an empty string.
4. It’s setting the data property of $res to an empty array.
5. It’s setting the error property of $res to an empty array.

Similar Posts