PHP code example of micdog / cnpj-alfa

1. Go to this page and download the library: Download micdog/cnpj-alfa 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/ */

    

micdog / cnpj-alfa example snippets


use MicDog\CnpjAlfa\CnpjAlfa;

// Validar
$ok  = CnpjAlfa::validate('12ABC34501DE35'); // true/false
$fmt = CnpjAlfa::format('12abc34501de35');   // "12.ABC.345/01DE-35"

// Calcular DV (quando você tem só os 12 primeiros)
[$dv1, $dv2] = CnpjAlfa::computeDv('12ABC34501DE'); // [int, int]
bash
php bin/demo "12ABC34501DE35" "59.952.259/0001-85"