AuthenticationStorage breaks: Object of class PHPIncompleteClass could not be converted to string #349 aeneasr opened this issue Dec 1, 2013 4 comments Comments.
I want to create CRUD data json in table. I want to send variable to client.php and create table in another php file, but in client PHP I want to test echo the variable. this code run if me print the variable from function
Line 208 is functions list_targets($data)
This vuforiaapi.php:
This class client:
Thanks for help.
You should not echo the result. Use the return
statement to return the result of a method / function instead.
There are some issues with your code and one will be throwing a 'Recoverable Fatal Error'. Let's start with the call of the method:
$data
as a parameter but it hasn't been created (at least in the section of code posted). This would raise an E_NOTICE.list_targets($data)
. If you later-on access it, it might give you unexpected results.$data
(as mentioned above not set before) and assign values to it using $data = $this->$json->results;
. If no ampersand is preceding a parameter in a function definition (e.g. function returnByRef(&$varName)
) the parameter cannot be changed within the function scope and will be the same as was passed in into the function.result->getBody()
and assign it to $json
. This will now be an object, array or variable, depending on the returned data.$this
and try to access its property $json
. Not only this, you are chaining a method call to it. This property hasn't been set (and I would strongly advise against 'variable variables' like $this->$property
) so you are now calling a method on a non-object. The proper variable would have been the local variable $json
.Changed code
In fact you would only have to return the decoded JSON like so:
To be honest - and comments would be highly appreciated - I still wonder why this causes a 'could not be converted to string' error. Only idea would be that the raised exception is somehow trying to call __toString()
on a non-object.