English 中文(简体)
在穿戴一名JSON的画面时,为什么看上去的是一位领导吗?
原标题:When encoding a JSON string, why does a leading 0 appear?
  • 时间:2011-10-28 11:35:19
  •  标签:
  • php
  • json

我在使用<代码>json_encode功能时,有一个PHP单一尺寸阵列,我收到了一个 j子物体的回来,但在开张的曲线<代码><>>>>之前,它具有领先地位。

0{"a1000":"b1000","a1200":"b1200"}

PHP阵列如下:

Array
(
    [a1000] => b1000
    [a1200] => b1200
)

在同一页,由于申请不同(但结构上相同),被送回的json物体没有领先。

“ Chrome”中的错误是:

<编码> UncaultyntaxError: Unexpected token{

此前是否有人来过这一问题?

最佳回答

您的PHP有可能在JSON之前输出0。 虽然你没有显示你的所有法典,但你应该把以下所有内容增加一倍:

  • check there s no text before your <?php tag
  • look for any rogue echo or print statements
  • check that you re not using outputting functions such as readfile() or var_dump()
问题回答

暂无回答




相关问题
Brute-force/DoS prevention in PHP [closed]

I am trying to write a script to prevent brute-force login attempts in a website I m building. The logic goes something like this: User sends login information. Check if username and password is ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

定值美元

如何确认来自正确来源的数字。

Generating a drop down list of timezones with PHP

Most sites need some way to show the dates on the site in the users preferred timezone. Below are two lists that I found and then one method using the built in PHP DateTime class in PHP 5. I need ...

Text as watermarking in PHP

I want to create text as a watermark for an image. the water mark should have the following properties front: Impact color: white opacity: 31% Font style: regular, bold Bevel and Emboss size: 30 ...

How does php cast boolean variables?

How does php cast boolean variables? I was trying to save a boolean value to an array: $result["Users"]["is_login"] = true; but when I use debug the is_login value is blank. and when I do ...

热门标签