by Amit05 » Fri Aug 21, 2009 9:58 am
Finally I could resolve the issue by adding following line at the beginning of the file.
In the file, on 31st line, add the following :
ini_set('error_reporting',E_ALL);
Basically, we are suppressing the warnings that php is giving. This does not solve the root cause of the issue which is explained @http://www.trash-factor.com/content/php-error-creating-default-object-empty-value as below :
PHP Error: Creating default object from empty value
Submitted by trash-master on Thu, 02/05/2009 - 12:38
PHP 5 introduces the E_STRICT error reporting constant. The PHP manual states "Enable to have PHP suggest changes to your code which will ensure the best interoperability and forward compatibility of your code.". Thus it's recommendable to enable strict PHP errors.
About strict mode (E_STRICT)
Enabling the strict mode is done via the INI file (php.ini) or via code during runtime:
ini_set('error_reporting', E_ALL | E_STRICT);
The above code sets error_reporting to E_ALL and E_STRICT, because E_STRICT is not part of the E_ALL constant.
Disabling the strict mode works vice versa:
ini_set('error_reporting', E_ALL);
"Creating default object from empty value"
This error tells you your code instantiated a default object (of type stdClass) implicitely. The referenced part of your code most likely looks like
$object->foo = 'bar';
PHP is strict and doesn't accept this, because you didn't create the $object explicitely! The solution to this is rather simple: add the explicit instantiation and you're done! The code should look like:
$object = new stdClass(); // instantiate $object explicitely
$object->foo = 'bar'; // now it's save to do this!
Hope this helps someone. Unfortunately, the Google also failed to provide any pointers and I eventually spent 2 days trying to figure out the solution. Finally, a friend helped me out.