Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

PHP implementation of the Luhn algorithm.

License

NotificationsYou must be signed in to change notification settings

tdely/luhn-php

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 

Repository files navigation

PHP implementation of the Luhn algorithm. Commonly used in identificationnumbers, including IMEI and credit card numbers.

Unlike some implementations this one handles both odd and even number ofdigits.

Example

<?php// Preferably autoload instead of using requirerequire'src/Luhn.php';useTdely\Luhn\Luhn;$original =82356937851;// Calculate check digitvar_dump(Luhn::checksum($original));// int(1)// Calculate and add check digit to number$checksum = Luhn::create($original);var_dump($checksum);// string(12) "823569378511"// Validate numbersvar_dump(Luhn::isValid($original));// bool(false)var_dump(Luhn::isValid($checksum));// bool(true)

Releases

No releases published

Packages

No packages published

Languages


[8]ページ先頭

©2009-2025 Movatter.jp