Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/265.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PHP数组不适用于Google云消息传递_Php_Arrays_Google Cloud Messaging - Fatal编程技术网

PHP数组不适用于Google云消息传递

PHP数组不适用于Google云消息传递,php,arrays,google-cloud-messaging,Php,Arrays,Google Cloud Messaging,我正试图通过GCM发送一系列信息。但我遇到了一个令人沮丧的问题 这是表格 <form id="<?php echo $row["device_id"] ?>" name="" method="post" onsubmit="return sendPush('<?php echo $row["device_id"] ?>')"> <label>Name: </label> <span><?php echo $row["d

我正试图通过GCM发送一系列信息。但我遇到了一个令人沮丧的问题

这是表格

<form id="<?php echo $row["device_id"] ?>" name="" method="post" onsubmit="return sendPush('<?php echo $row["device_id"] ?>')">
<label>Name: </label> <span><?php echo $row["device_name"] ?></span>
<div class="clear"></div>
<div class="send_container">                                
<div>Hour:<input type="text" name="hour" class="txt_message" placeholder="Enter start hour" size="10"><br></div>
<div>Min :<input type="text" name="minute" class="txt_message" placeholder="Enter start minute" size="10"><br></div>                                        
<input type="hidden" name="regid" value="<?php echo $row["gcm_regid"] ?>"/>
<input type="submit" class="send_btn" value="Send" onclick=""/>
</div>
</form>
该函数调用以下函数

<?php
if (isset($_POST["regid"])) {
    $regid = $_POST["regid"];
    $hour = $_POST["hour"];
    $minute = $_POST["minute"];
    $message = 'TEST';

    include_once 'GCM.php';

    $gcm = new GCM();

    $registatoin_ids = array($regid);
    $message = array("message" => $message, "hour" => $hour , "minute" => $minute);

    $result = $gcm->send_notification($registatoin_ids, $message);

    echo $result;
}
?>
但是,如果我将上面的数组更改为静态值,它就会工作

myapp(1376): Message: Bundle[{message=ALARM, minute=2, android.support.content.wakelockid=12, hour=1, collapse_key=do_not_collapse, from=270774530472}]
为什么没有发送第二和第三个POST值? 这几天我都快发疯了


谢谢

当您记录print\u r$\u POST;,您会看到什么?如果我将表单操作更改为带有var_转储的test.php,我会得到。。。array3{[message]=>string5 TEST[hour]=>string3 123[minute]=>string3 456}也许你可以用intval$string将你的字符串转换为int?如果我发布字符串或int,这是同样的行为。现在唯一的区别是你没有使用有效的小时123和分钟456。你能给我看一下GCM课程吗?
myapp(1376): Message: Bundle[{message=TEST, android.support.content.wakelockid=11, collapse_key=do_not_collapse, from=270774530472}]
myapp(1376): Message: Bundle[{message=ALARM, minute=2, android.support.content.wakelockid=12, hour=1, collapse_key=do_not_collapse, from=270774530472}]