1. Go to this page and download the library: Download ilexn/hkid-check-digit library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
ilexn / hkid-check-digit example snippets
//4.x
switch ($hkid->getReason()){
case \Ilex\Validation\HkidValidation\Reason\ReasonInterface::OK:
echo('correct');
echo($hkid->format());
break;
case \Ilex\Validation\HkidValidation\Reason\ReasonInterface::PATTEN_ERROR:
echo('Patten not match');
break;
case \Ilex\Validation\HkidValidation\Reason\ReasonInterface::DIGIT_ERROR:
echo('Digit not match');
break;
}
//5.x
switch ($hkid->getReason()){
case \Ilex\Validation\HkidValidation\Enum\Reason::Ok:
echo('correct');
echo($hkid->format());
break;
case \Ilex\Validation\HkidValidation\Enum\Reason::PattenError:
echo('Patten not match');
break;
case \Ilex\Validation\HkidValidation\Enum\Reason::DigitError:
echo('Digit not match');
break;
}
use Ilex\Validation\HkidValidation\Helper;
//>=3.x
$a->isValid(); //bool
$a->isPattenError(); //bool
$a->isDigitError(); //bool
echo($a->format()); // print the formated HKID.
echo($a->getReason());
//also can get back each parts
echo($a->getPart1());
echo($a->getPart2());
echo($a->getPart3());
use Ilex\Validation\HkidValidation\Enum\Reason;use Ilex\Validation\HkidValidation\Helper;
\Ilex\Validation\HkidValidation\Enum\Reason::Ok:
echo('correct');
echo($hkid->format());
break;
case \Ilex\Validation\HkidValidation\Enum\Reason::PattenError:
echo('Patten not match');
break;
case \Ilex\Validation\HkidValidation\Enum\Reason::DigitError:
echo('Digit not match');
break;
use Ilex\Validation\HkidValidation\HkidDigitCheck;
';
$c = new HkidDigitCheck();
$hkid = $c->checkParts($p1,$p2,$p3);
if ($hkid->isValid()) {
echo ('correct');
echo $hkid->format();
} else {
echo ('wrong');
if ($hkid->isPattenError()) {
echo('Patten not match');
}
if ($hkid->isDigitError()) {
echo('Digit not match');
}
}
$hkid = $c->checkString($s);
if ($hkid->isValid()) {
echo ('correct');
echo $hkid->format();
} else {
echo ('wrong');
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.