Jason
Jason

Reputation: 133

The authoritative way to pass values from PHP to Javascript

I guess I am looking for a best method of passing values: arrays, objects, JSON -- any data -- from PHP to javascript.

So far I've just seen:

   PHP - json_encode(value); 
   Javascript - eval()

and a variation of that by using json2.js or the alike.

Upvotes: 0

Views: 214

Answers (1)

jerone
jerone

Reputation: 16871

PHP has:

JavaScript (json2.js) has:

  • JSON.stringify --> encode
  • JSON.parse --> decode

Upvotes: 3

Related Questions