-
Notifications
You must be signed in to change notification settings - Fork 4
getCIFCheckDigit
elcapo edited this page Oct 16, 2014
·
5 revisions
getCIFCheckDigit
obtains and returns the corresponding check digit for a given string. In order to work, the string must match the CIF pattern.
This function has been written to be used from isValidCIF as a helper, but it can still be calle directly.
/* MySQL */
SELECT getCIFCheckDigit( 'H24930830' ); /* Returns '6' */
SELECT getCIFCheckDigit( '1A1A1A1A' ); /* Returns '' */
/* JavaScript */
var digit = getCIFCheckDigit( 'H24930830' ); /* digit = '6' */
var digit = getCIFCheckDigit( '1A1A1A1A' ); /* digit = '' */
/* PHP */
$digit = getCIFCheckDigit( 'H24930830' ); /* $digit = '6' */
$digit = getCIFCheckDigit( '1A1A1A1A' ); /* $digit = '' */
[char]
- If the string does math the CIF pattern, returns the corresponding check digit.
[empty]
- If the string doesn't math the CIF pattern, returns an empty string.
In order to verify the format of the string received as parameter, this function uses isValidCIFFormat
.
This function is part of the NIF, NIE & CIF package.
Go back home!
SEPA validations
- [International Bank Account Numbers (IBAN)](International Bank Account Numbers (IBAN))
Spanish validations
- NIF, NIE & CIF
- [Spanish Bank Accounts](Spanish Bank Accounts)
Helpers
- [Common functions](Common functions)