substr($id, 0, 17), 'addressCode' => substr($id, 0, 6), 'birthdayCode' => substr($id, 6, 8), 'order' => substr($id, 14, 3), 'checkBit' => substr($id, -1), 'type' => 18, ]; break; case 15: $code = [ 'body' => $id, 'addressCode' => substr($id, 0, 6), 'birthdayCode' => '19'.substr($id, 6, 6), 'order' => substr($id, 12, 3), 'checkBit' => '', 'type' => 15, ]; break; } return $code; } /** * 检查地址码 * * @param string $addressCode 地址码 * * @return bool */ private function _checkAddressCode($addressCode) { $addressInfo = $this->_getAddressInfo($addressCode); return $addressInfo ? true : false; } /** * 检查顺序码 * * @param string $orderCode 顺序码 * * @return bool */ private function _checkOrderCode($orderCode) { if (strlen($orderCode) == 3) { return true; } else { return false; } } /** * 检查出生日期码 * * @param string $birthdayCode 出生日期码 * * @return bool */ private function _checkBirthdayCode($birthdayCode) { $year = intval(substr($birthdayCode, 0, 4)); $month = intval(substr($birthdayCode, 4, 2)); $day = intval(substr($birthdayCode, -2)); if ($year < 1800) { return false; } if ($month > 12 || $month === 0 || $day > 31 || $day === 0) { return false; } return true; } }