我有PHP的要求,
从生物识别机器中,URL将如下传递:
website.com/rfid/attendance.php? - Web主机URL
$ - Start of data
SID= XXXXX - Org ID (5 digits)
& - Field Differentiator
MID= XX - Machine ID (2 digits)
&
RFID= XXXXXXXXXX - Card ID (10 numeric digits User ID)
&
DOT=DDMMYYYYHHMMSS- Date of Transaction (14 digits)
, - End of one record
* - End of data
如果要一次上传一条记录:
http://website.com/rfid/attendance.php?$99999&99&0008478100&27122013113700*
如果要同时上传两个记录:
http://website.com/rfid/rfid_device.php?$99999&99&0008478100&27122013113700, 0008478200&27122013113700*
当一次上传10条记录时:
/rfid/rfid_device.php?0000000000000000$99999&99&0008478100&27122013113700,1234567100&27122013113700,1234567200&27122013113700,123456700&27122013113700,1234567200&27122013113700,1234567100&27122013113700,1234567100&27122013113700,1234567200&27122013113700,1234567100&27122013113700,1234567200&27122013113700*
如何获得商店价值?请帮忙。
答案 0 :(得分:3)
你可以使用$_SERVER['QUERY_STRING']
super,然后只使用explode()
来分解字符串...
http://php.net/manual/en/reserved.variables.server.php
http://php.net/manual/en/function.explode.php
<强>更新强>
未经测试的代码示例:(应该注意的是,我不记得超级是否包含查询字符串中的'?'。)
$qs = str_replace('$', '', $_SERVER['QUERY_STRING']); // get rid of the $
$qs = str_replace('*', '', $qs); // get rid of the *
$submissions = explode(',', $qs); // split the subs
$SID = ""; // store for sid
$MID = ""; // store for mid
// loop
for ($i = 0; $i < count($submissions); $i++) {
$sections = explode('&', $submissions[$i]);
if($i == 0) {
$SID = $sections[0];
$MID = $sections[1];
$RFID = $sections[2];
$DOT = $sections[3];
} else {
$RFID = $sections[0];
$DOT = $sections[1];
}
// do things with the values
}
答案 1 :(得分:-1)
PHP还建议使用Filter API直接访问$ _ *变量。
$querystr = filter_input( INPUT_SERVER, 'QUERY_STRING' );