调用数组中的参数 - 当前返回空值

时间:2017-04-30 16:19:22

标签: php arrays

我有以下内容:

>>XXXX<<

JSON sent: {"app_id":null,"included_segments":["All"],"data":{"foo":"bar"},"contents":{"en":"English Message"}}

输出以下内容:

{{1}}

$ curAppId在my-settings.php文件中设置了值XXXX。事实上,它是正确的。但是在数组中它被视为无效。

你能帮忙吗?

2 个答案:

答案 0 :(得分:0)

你有拼写错误你在$ currAppId引用的数组中引用了$ curAppId。我修正了下面的拼写错误

require 'my-settings.php';

echo '>>'.$curAppId.'<<';
$content = array(
                 "en" => 'English Message'
                 );

$fields = array(
                'app_id' => $curApId, //Had two r's
                'included_segments' => array('All'),
                'data' => array("foo" => "bar"),
                'contents' => $content
                );

$fields = json_encode($fields);
print("\nJSON sent:\n");
  

这就是我们所说的程序员的噩梦,但在你的情况下是一个   错误会告诉你问题^,^

答案 1 :(得分:0)

你有一个错字:

'app_id' => $curAppId,
相关问题