Strict Standards: Creating default object from empty value

Ask community to help.

Moderators: Amaradana, TurboPT, TL Developers

Post Reply
Amit05
TestLink user
Posts: 6
Joined: Wed Aug 19, 2009 7:00 pm

Strict Standards: Creating default object from empty value

Post by Amit05 »

Hi there,
I just installed testlink version 1.8. After installation, when I try to login, I bump into the error message as below:
"Strict Standards: Creating default object from empty value in /opt/lampp/htdocs/testlink/cfg/const.inc.php on line 615"

The page shows nothing else but this. Could you please help.

Regards.
Amit05
TestLink user
Posts: 6
Joined: Wed Aug 19, 2009 7:00 pm

Re: Strict Standards: Creating default object from empty val

Post by Amit05 »

Amit05 wrote:Hi there,
I just installed testlink version 1.8. After installation, when I try to login, I bump into the error message as below:
"Strict Standards: Creating default object from empty value in /opt/lampp/htdocs/testlink/cfg/const.inc.php on line 615"

The page shows nothing else but this. Could you please help.

Regards.
Hey Folks.. Any help ??
Amit05
TestLink user
Posts: 6
Joined: Wed Aug 19, 2009 7:00 pm

Post by Amit05 »

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 ... mpty-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.
sn82w
Advanced user
Posts: 45
Joined: Fri Apr 27, 2012 6:38 pm

Re: Strict Standards: Creating default object from empty val

Post by sn82w »

Hi, am also facing the issue in testlink
Warning: Creating default object from empty value in C:\xampp\htdocs\testlink\config.inc.php on line 558

Warning: Creating default object from empty value in C:\xampp\htdocs\testlink\config.inc.php on line 565

Warning: Creating default object from empty value in C:\xampp\htdocs\testlink\config.inc.php on line 580

Warning: Creating default object from empty value in C:\xampp\htdocs\testlink\config.inc.php on line 621

Warning: Creating default object from empty value in C:\xampp\htdocs\testlink\config.inc.php on line 624

Warning: Creating default object from empty value in C:\xampp\htdocs\testlink\config.inc.php on line 627

Warning: Creating default object from empty value in C:\xampp\htdocs\testlink\config.inc.php on line 631

Warning: Creating default object from empty value in C:\xampp\htdocs\testlink\config.inc.php on line 640

Warning: Creating default object from empty value in C:\xampp\htdocs\testlink\config.inc.php on line 697

Not able to get any page.
Please give me some solutions to resolve this ..
thanks in advance.
fman
Member of TestLink Community
Posts: 3123
Joined: Tue Nov 15, 2005 7:19 am

Re: Strict Standards: Creating default object from empty val

Post by fman »

very bad practice post on TWO areas of forum, you are not getting more help this way, but risking that your user will be banned
Post Reply