Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Loading JSON with PHP

Tags:

json

php

I've been using PHP for too long, but I'm new to JavaScript integration in some places.

I'm trying to find the fastest way to pass database information into a page where it can be modified and displayed dynamically in JavaScript.

Right now, I'm looking at loading a JSON with PHP echo statements because it's fast and effective, but I saw that I could use PHP's JSON library (PHP 5.2).

Has anybody tried the new JSON library, and is it better than my earlier method?

like image 541
jgreenawalt Avatar asked Sep 02 '08 20:09

jgreenawalt


1 Answers

Use the library. If you try to generate it manually, I predict with 99% certainty that the resulting text will be invalid in some way. Especially with more esoteric features like Unicode strings or exponential notation.

like image 151
John Millikin Avatar answered Sep 29 '22 00:09

John Millikin