PHP code example of springy-framework / brazilian-numbers
1. Go to this page and download the library: Download springy-framework/brazilian-numbers 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/ */
springy-framework / brazilian-numbers example snippets
e following numbers can also be used without a mask.
$cpf = '899.678.736-12';
$cnpj = '76.871.442/0001-75';
$cnh = '21059294129';
$nis = '640.58791.38-4';
$ierj = '18.251.03-5';
if (Springy\Utils\BrazilianNumbers\Cpf::isValid($cpf)) {
echo "CPF valid!\n";
} else {
echo "CPF invalid!\n";
}
if (Springy\Utils\BrazilianNumbers\Cnpj::isValid($cnpj)) {
echo "CNPJ valid!\n";
} else {
echo "CNPJ invalid!\n";
}
if (Springy\Utils\BrazilianNumbers\Cnh::isValid($cnh)) {
echo "CNH valid!\n";
} else {
echo "CNH invalid!\n";
}
if (Springy\Utils\BrazilianNumbers\Nis::isValid($nis)) {
echo "NIS valid!\n";
} else {
echo "NIS invalid!\n";
}
if (Springy\Utils\BrazilianNumbers\InscricaoEstadual::isValid($ierj)) {
echo "IE valid!\n";
} else {
echo "IE invalid!\n";
}
echo Springy\Utils\BrazilianNumbers\Cpf::mask('89967873612');
echo Springy\Utils\BrazilianNumbers\Cnpj::mask('76871442000175');
echo Springy\Utils\BrazilianNumbers\Nis::mask('64058791384');
echo Springy\Utils\BrazilianNumbers\InscricaoEstadual::mask('18251035');
echo Springy\Utils\BrazilianNumbers\Cpf::unmask($cpf);
echo Springy\Utils\BrazilianNumbers\Cnpj::unmask($cnpj);
echo Springy\Utils\BrazilianNumbers\Nis::unmask($nis);
echo Springy\Utils\BrazilianNumbers\InscricaoEstadual::unmask($ierj);