1

Im getting what seems to be a common error in my php log, but cant seem to resolve based on other threads..

Im getting the error: PHP Warning: Creating default object from empty value in

Pointing at the following code:

$status = new \stdClass();

$status->about->requester       = $username;
$status->about->method          = $method;
$status->about->command         = $cmd;

The other posts all say to use ( $status = new \stdClass(); ) or variations of. I've tried them all, but the error persists.

Any thoughts?

Driving me insane as the log is somewhat very big and this is my only error.

1 Answer 1

1

The error is not about $status object, but $status->about. Assign an instance of stdClass to it first and the error will go.

$status = new \stdClass();

$status->about = new \stdClass();

$status->about->requester       = 'username';
$status->about->method          = 'method';
$status->about->command         = 'cmd';
Sign up to request clarification or add additional context in comments.

5 Comments

No, there is no error after adding such assignment. sandbox.onlinephpfunctions.com/code/…
yeah im sure. :( unfortunately at this end it persists. Even if i put your exact copy from the sandbox into a test.php file, it then shows the same error. php --version PHP 7.2.24-0ubuntu0.18.04.4 (cli) (built: Apr 8 2020 15:45:57) ( NTS ) Copyright (c) 1997-2018 The PHP Group Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies with Zend OPcache v7.2.24-0ubuntu0.18.04.4, Copyright (c) 1999-2018, by Zend Technologies
Well, if you say that even file that contains only the code from the sandbox still shows the error, I think you might have some custom code auto-appended due to option defined in php.ini. Try to run php -i | grep pend and make sure auto_append_file and auto_prepend_file are emty. Then run php test.php.
Nothing stands out. Its a very new install too. Like. apt installed apache2 and php.. Nothings really changed other than a few vhosts. Sooo weird ,, painfully weird.
Think ill just have to put this down to some oddity, clearly its an issue here. Cheers

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.