Responsive site design and the active site are a must in today’s world because approximately billions of devices are in use. Everybody has no time to wait for anything, so these kinds of errors “Creating default object from empty value” will lead your business and position down.
An immeasurable first impression on any new user is critical and requires our attention. Unfortunately, early versions of Elegant Themes’ update checking code contained a tiny flaw. Occasionally, an error displays in the WordPress Dashboard. It may be the cause of some plugin or shortcode that you last entered.
Many of Elegant Theme’s products fix the error such as the Divi Theme and Extra Theme. However, some of their shortcode and portable plugins continue to have issues.
Warning: Creating default object from empty value in Divi theme
Warning: Creating default object from empty value in C:\aggregate\wp-content\plugins\et-codes\et-shortcodes5.php on line 180
It’s a slight inconvenience that does not affect the functionality of the themes or plugins.
$last update->last checked = time()
This line of code (which can be in the file and at the line number specified in the warning notice) causes the problem.
It’s trying to set a property of the last_update object. The issue is that the previous update object hasn’t been declared yet, so PHP issues the warning to remind developers to declare the object first.
So, How to fix this issue? Here are a few possibilities:
- First, this error can be fixed by updating the WordPress admin dashboard’s elegant theme and clicking on the update button. So, install the latest version of your Divi theme.
- Second Disable the php.ini file: This method can tell the PHP not to show these notifications or warnings.
- Find the “error_reporting = E_ALL” in the .php.ini file and replace with “error_reporting = E_ALL & ~E_NOTICE & ~E_WARNING”
- Follow the appropriate change to the plugin/theme line: @$last update->last checked = time();
Empty Value In PHP
It seems that after upgrading my PHP environment to PHP 5.4 and beyond encounter this problem. The error is leading to the following line of code:
Error:
Creating default object from empty value
Code:
$res->success = false;
Solution:
E_STRICT warnings may be enabled in error reporting for PHP versions >= 5.3.x, or error reporting set to at least E_WARNING for PHP versions >= 5.4 in your new environment. For example, when $res is NULL or not yet initialized, an error occurs:
$res = NULL;
$res->success = false; // Warning: Creating default object from empty value
If $res is already initialized to a value but is not an object, PHP will display a different error message:
$res = 33;
$res->success = false; // Warning: Attempt to assign property of non-object
Suppose you’re attempting to build a generic object and assign the property success. In that case, you’ll need to define $res as an object of stdClass in the global namespace to comply with E STRICT standards previous to PHP 5.4, or the regular E WARNING error level in PHP >= 5.4:
$res = new \stdClass();
$res->success = false;