PECL json version 1.2.1 gives a warning when i try to pass a second argument to json_encode

146 views
Skip to first unread message

ramow

unread,
Jul 20, 2009, 6:23:40 PM7/20/09
to php-json
I am running PHP Version 5.1.3 with json version 1.2.1
json_encode works fine if I don't supply the second argument
"$options" specified in the documentation:

string json_encode ( mixed $value [, int $options= 0 ] )


If I write the following line:
json_encode( $this->json, JSON_FORCE_OBJECT );

I get this warning:
Use of undefined constant JSON_FORCE_OBJECT - assumed
'JSON_FORCE_OBJECT'

and if I use an integer instead if the constant:
json_encode( $this->json, 4 );

I get:
Warning: json_encode() expects exactly 1 parameter, 2 given in


Any ideas why it is not work?

--ramow

Dennis Gearon

unread,
Jul 20, 2009, 7:25:45 PM7/20/09
to php-...@googlegroups.com

Probably only available in a later version.

Try downloading the CLI verstion (local executable), and execute that statement there.


Dennis Gearon

Signature Warning
----------------
EARTH has a Right To Life

I agree with Bolivian President Evo Morales

# The right to life: "The right for no ecosystem to be eliminated by the irresponsible acts of human beings."

# The right of biosystems to regenerate themselves: "Development cannot be infinite. There's a limit on everything."

# The right to a clean life: "The right for Mother Earth to live without contamination, pollution. Fish and animals and trees have rights."

# The right to harmony and balance between everyone and everything: "We are all interdependent."


See the movie - 'Inconvenient Truth'
See the movie - 'Syriana'


--- On Mon, 7/20/09, ramow <rami.c...@gmail.com> wrote:
Reply all
Reply to author
Forward
0 new messages