Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8473929
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T17:29:23+00:00 2026-06-10T17:29:23+00:00

How can I convert the PHP variable in server side to the JSON object?

  • 0

How can I convert the PHP variable in server side to the JSON object?
I am thinking to first use JSON encode function and then after eval function. Is this the right way? Can I change directly or not?

why encode and decode process in server side? And what the serializer do in the client browser side?

So the flow of process: In server side encode php varialble to JSON string and the decode JSON string to Javascript Object and In server side perform serialization with stringify function and Parse to get data. Am I right?

Can not I directly send the JSON string after encoding?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T17:29:25+00:00Added an answer on June 10, 2026 at 5:29 pm

    Why do you want to use eval()? After conversion to JSON, the object is represented as a string ready to transfer. You do not edit the JSON directly, but use your native objects until they are ready and then serialize them using JSON.

    On the server:

    • Encoding: json_encode() (PHP docu)
    • Decoding: json_decode() (PHP docu)

    On the client (browser):

    • Encoding: JSON.stringify() (MDN docu)
    • Decoding: JSON.parse() (MDN docu)

    EDIT

    With respect to the question’s edit:

    JSON is just another kind of serialization. Inspired by the short hand object/array notation of JavaScript. You can use it in almost any situation, where serialization is required (persisting objects, transferring objects over some network, …).

    The big advantage of using JSON in web environments is its native support inside browsers and its rather compact form. Almost all browsers have some kind of JSON encode and decode functions and, if they do not, you can use libraries like jQuery to support JSON.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How can I convert php's POST variable to json format?
How can I convert an array to a SimpleXML object in PHP?
I use stdClass to convert an array to an object, function array_to_object($array) { if(!is_array($array))
First I thought that I had to convert JavaScript to PHP, but then I
I want to know can I convert a php $_POST variable into a jquery
How can I convert a PHP variable from My company & My Name to
Using PHP, I can convert MySQL data or static table data to csv, Excel,
Can anyone convert this curl command that works in command line to php code
How can I convert from bytes to float in php? Like in Java int
How can I convert a javascript array to a php array?? I have a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.