Re: Proposed feature for json_encode()
| From: | Rasmus Lerdorf | Date: | Mon, 03 Dec 2007 17:30:02 +0000 |
| Subject: | Re: Proposed feature for json_encode() | ||
| References: | 1 2 3 4 5 6 7 8 9 10 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-33587@lists.php.net to get a copy of this message | ||
Alexey Zakhlestin wrote:
> On 12/2/07, Rasmus Lerdorf <rasmus@lerdorf.com> wrote:
>> The \u syntax is specific to JSON, yes.
>
> \u syntax is specific to javascripts string literals, regular
> expressions and identifiers[1]
> And JSON is not the only way to deliver data into javascript. Manual
> approaches are still useful
Since JSON and Javascript are synonymous, sure, \u is for javascript
string literals. I thought you meant whether it was useful outside of
Javascript.
And I disagree with your second statement. Why wouldn't you use json
anytime you wanted to jump from PHP to Javascript?
<script>
var a = <?php echo json_encode($a)?>;
</script>
That ensures that no matter what $a is on the PHP side, it will be
correctly assigned to the corresponding Javascript variable.
-Rasmus