2008/12/15 mike <mike...@gmail.com>:
> On Mon, Dec 15, 2008 at 9:50 AM, Rasmus Lerdorf <ras...@lerdorf.com> wrote:
>
>> 1. Document the fact that if you want to strictly conform to the JSON
>>   spec and be sure your json_encode output will work in various JSON
>>   parsers, you have to pass it a PHP array or object.
>
> Instead of json_encode(34) the suggestion would be
> json_encode(array(34)) ? Seems kind of like a lame thing to require.
> IMHO the language should "do the right thing" as far as the consumer
> (javascript/JSON parser) is concerned. However, Douglas is infinitely
> more educated than I am here. This is just my $0.02 as a PHP user.

I was one of those that read the PHP dox and not the RFC/standard
(http://bugs.php.net/bug.php?id=38680).

I would say that having PHP "correct" my mistake is wrong.

If I say...

 json_encode(34);

 I am saying that I expect the result to be ...

var i_SomeInt = 34;

And from there I would expect to be able to say ...

var i_SomeOtherInt = i_SomeInt + 10;

This is not going to work if PHP "corrects" my mistake.

I'd be perfectly happy for the standard to be enforced and an E_STRICT
warning to be raised.

If I want to shoot myself then I have to at least take the safety off
first - turning off E_STRICT that is.

Essentially, I don't like computers guessing my intent. If I don't
state it clearly enough then it may be that I don't know what I'm
doing.

GIMGO (Garbage In, Maybe Garbage Out) isn't a good way to go.

Richard.

-- 
-----
Richard Quadling
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
"Standing on the shoulders of some very clever giants!"

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to