php - Copy object to array converts it to string
Get the solution ↓↓↓In a wordpress plugin I'm writing a script to copy a bunch of WP_POST objects. I don't think it matters for this question what type of object it is I have or what data it has, I'm trying to simply copy the object to an array with the code below and I get the error Object could not be converted to string. Several objects can be copied before this error is thrown so maybe it is something to do with the data but I'm printing it out and it looks fine to me.
Why is saving the object to the array trying to convert it to a string?
$result['post'] = $post;
Uncaught Error: Object of class WP_Post could not be converted to string in /home/staticfiles/staging.webbskisser.se/karlshamnwcag/wp-content/plugins/kpm/admin/class-kpm-admin-ajax.php on line 214
Share solution ↓
Additional Information:
Link To Answer People are also looking for solutions of the problem: call to a member function getclientoriginalname() on null
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.