Convert an Object to a String in PHP

后端 未结 2 1744
清酒与你
清酒与你 2020-12-19 19:08

I want to convert an Object into a String in PHP. Specifically, I\'m trying to take a mysql query response, and I\'m trying to convert it into something I can write to a fil

相关标签:
2条回答
  • 2020-12-19 19:29

    json_encode and json_decode will also accomplish many of the properties you are looking for via serialize. The advantage is that you can send JSON-encoded data to a web browser and JavaScript can view and modify properties like a native JavaScript object. In addition, JSON is lighter weight than serialized data because its syntax is a lot more compact.

    0 讨论(0)
  • 2020-12-19 19:45

    Maybe serializing? It will take an object/array and convert it to a string (which can then be un-serialized back later)

    0 讨论(0)
提交回复
热议问题