定制 yhdleung/hkid-util 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

yhdleung/hkid-util

Composer 安装命令:

composer require yhdleung/hkid-util

包简介

Utility functions for tasks related to Hong Kong Identity Card (HKID)

README 文档

README

PHP Utility functions designed to help tasks related to Hong Kong Identity Card (HKID).

Latest Stable Version License

Features

  • Support two-letter prefix (e.g. AB987654(3))
  • For HKID input, parentheses are optional

Requirement

  • PHP 5.3+

Functions

  • getCheckDigit - Get the Check Digit of HKID
char HKIDUtil::getCheckDigit(string $id)
  • validateHKID - Validate HKID format
bool HKIDUtil::validateHKID(string $id)
  • randomHKID - Generate random HKID
string HKIDUtil::randomHKID(bool $hasParentheses=true)
  • validateDate - Validate date format in 'dd-mm-yyyy' or 'dd/mm/yyyy'
bool HKIDUtil::validateDate(string $date)

Installation

Include the utility function file

require_once("HKIDUtil.php");

Usage

Get the Check Digit of a HKID

$testID = 'C123456';
echo(HKIDUtil::getCheckDigit($testID));  // returns '9'

Validate HKID format, check digit parentheses are optional

var_dump(HKIDUtil::validateHKID('AB987654(3)'));   // bool(true)

if(HKIDUtil::validateHKID('AB9876543')){ 
    echo 'valid'; 
}     //returns 'valid'

Generate random HKID

echo(HKIDUtil::randomHKID());     // returns HKID, e.g. 'LA654668(9)'

for($i = 0; $i < 3; $i++){
    echo(HKIDUtil::randomHKID(0)) . PHP_EOL;
}
// returns HKID without parentheses, e.g. 
// 'Q2127047'
// 'J9009792'
// 'BA1196657'

Validate date format in 'dd-mm-yyyy' or 'dd/mm/yyyy'

var_dump(HKIDUtil::validateDate('31-12-1969'));     // bool(true)
var_dump(HKIDUtil::validateDate('01/01/1970'));     // bool(true)
var_dump(HKIDUtil::validateDate('1/1/1970'));       // bool(true)
var_dump(HKIDUtil::validateDate('30/02/1970'));     // bool(false)

License

See the LICENSE file for license rights and limitations (MIT).

Reference

This HKID validation formula is developed based on the information from Wikipedia.
維基百科, 香港身份證 (Wikipedia, Hong Kong Identity Card)

Contribution

Star, fork, pull request and issue report are all welcome.

统计信息

  • 总下载量: 60
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-03-09

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固