2017-04-30 57 views
-1

我有以下几点:调用参数 - 目前返回null

require 'my-settings.php'; 

echo '>>'.$curAppId.'<<'; 

    $content = array(
        "en" => 'English Message' 
        ); 

    $fields = array(
        'app_id' => $curAppId, 
        'included_segments' => array('All'), 
        'data' => array("foo" => "bar"), 
        'contents' => $content 
        ); 

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

它输出如下:

>>XXXX<< 

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

$ curAppId具有价值XXXX集文件我的设置.PHP。实际上它正在正确回声。但在数组中它被视为空。

你能帮忙吗?

+2

'$ currApId' ='$ curApId'!过度。 –

+0

当您询问有关错误的问题时**总是**包含**错误记录**。添加'error_reporting(E_ALL); ini_set('display_errors',1);'在'php'脚本的顶部,它返回什么? –

+0

@u_mulder对不起,这是一个错字。我解决了它,但仍返回为空 – Rank

回答

0

你有一个拼写错误你引用$ curAppId然后在你引用$ currAppId的数组中。我固定的拼写错误下面

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"); 

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

+0

对不起,这是我在这里做的一个错字,但修复后它仍然返回为空。编辑我的原始帖子。 – Rank

0

你有一个错字:

'app_id' => $curAppId,