1. Go to this page and download the library: Download ernestochapon/rif-php 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/ */
ernestochapon / rif-php example snippets
rnestoChapon\Rif\Rif;
// Validación simple
if (Rif::isValid('V113502963')) {
echo "RIF válido!";
}
// Validación con manejo de excepciones
try {
$rif = Rif::create('J000029679');
echo "RIF: " . $rif->getRaw();
echo "Tipo: " . $rif->getType()->getDescription();
echo "Número: " . $rif->getNumber();
echo "Dígito verificador: " . $rif->getCheckDigit();
} catch (ErnestoChapon\Rif\Exceptions\RifValidationException $e) {
echo "Error: " . $e->getMessage();
}
// Validación de RIFs conocidos
$knownRifs = [
'V113502963', // RIF personal
'G200001100', // Banco Central de Venezuela
'J000029679', // Banco Provincial
];
foreach ($knownRifs as $rifString) {
if (Rif::isValid($rifString)) {
echo "$rifString es válido\n";
}
}