Re: [SOLVED] class to generate Javascript Object ??

Re: [SOLVED] class to generate Javascript Object ??

am 04.10.2009 20:04:16 von Michael Peters

Andrea Giammarchi wrote:
>
> > I'm thinking (hoping) there is already a php class somewhere for
> > generating JavaScript object strings that I can instead of my ugly
> > easily breakable way of doing it.
> >
> > Anyone know of one?
>
>
> json_encode
> http://uk3.php.net/manual/en/function.json-encode.php
>

Thank you, worked beautifully.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

RE: [SOLVED] class to generate Javascript Object ??

am 04.10.2009 20:12:59 von Andrea Giammarchi

--_d0511e57-0969-494f-a440-dc1528d8dddb_
Content-Type: text/plain; charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable




> Thank you=2C worked beautifully.

just don't ignore this:
PHP 5 >=3D 5.2.0

if you are trying to create something portable=2C you should consider a Pea=
r fallback ...

if(!function_exists('json_encode')){
require_once 'JSON.phps'=3B
// http://mike.teczno.com/JSON/JSON.phps
function json_encode($o){
$json =3D new Services_JSON=3B
return $json->encode($o)=3B
}
}

Regards
=0A=
____________________________________________________________ _____=0A=
Windows Live Hotmail: Your friends can get your Facebook updates=2C right f=
rom Hotmail=AE.=0A=
http://www.microsoft.com/middleeast/windows/windowslive/see- it-in-action/so=
cial-network-basics.aspx?ocid=3DPID23461::T:WLMTAGL:ON:WL:en -xm:SI_SB_4:092=
009=

--_d0511e57-0969-494f-a440-dc1528d8dddb_--

Re: [SOLVED] class to generate Javascript Object ??

am 04.10.2009 20:21:40 von Michael Peters

Andrea Giammarchi wrote:
>
>
>> Thank you, worked beautifully.
>
> just don't ignore this:
> PHP 5 >= 5.2.0
>
> if you are trying to create something portable, you should consider a Pear fallback ...

I make heavy use of DOMDocument so I need 5.2.x anyway.
But thanks for the warning.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php