You are developing a RESTful API in PHP and want to ensure that the response is always in JSON format. Which PHP function would you primarily use to convert the data to this format?

  • json_encode()
  • json_decode()
  • serialize()
  • unserialize()
The json_encode() function in PHP is used to convert data to JSON format. It's essential for generating JSON responses in a RESTful API.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *