1

I created an object from a class named Userprofile in PHP and tried to send via ajax using json_encode to update a web page. However the response in Ajax is an empty object. The e.g. below has the property name "userProfileId" and the class name "Userprofile" and the access modifier "private". How do I remove the class and access modifier from the object below? Thank you.

object(Userprofile)#3 (8) {
  ["userProfileId":"Userprofile":private]=>
  int(48)
  ["userId":"Userprofile":private]=>
  int(59)
  ["firstName":"Userprofile":private]=>
  string(5) "Benny"
  ["lastName":"Userprofile":private]=>
  string(5) "James"
  ["email":"Userprofile":private]=>
  string(15) "benny@gmail.com"
  ["accountTypeId":"Userprofile":private]=>
  int(2)
  ["created_On":"Userprofile":private]=>
  string(19) "2022-01-25 14:31:04"
  ["updated_On":"Userprofile":private]=>
  string(19) "2022-01-25 14:31:04"
}
  • Can you modify the Userprofile class? – Don't Panic Jan 26 '22 at 16:37
  • Does this answer your question? [json\_encode an array of objects with private properties](https://stackoverflow.com/questions/34710347/json-encode-an-array-of-objects-with-private-properties) or [PHP json_encode class private members](https://stackoverflow.com/questions/7005860/php-json-encode-class-private-members) – M. Eriksson Jan 26 '22 at 16:45

0 Answers0