PHP code example of avf / cnpj

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

    

avf / cnpj example snippets




use Avf\Cnpj\Cnpj;

$result = Cnpj::isValid(
    '93.015.006/0001-13'
);

var_dump($result);

bool(true)

$result = Cnpj::isValid(
    '93.015.006/0001-14'
);

var_dump($result);

bool(false)

$result = Cnpj::isValid(
    '112223AA000151'
);

var_dump($result);

bool(true)

echo Cnpj::format(
    '93015006000113'
);

echo Cnpj::removeMask(
    '93.015.006/0001-13'
);

echo Cnpj::calculateDv(
    '930150060001'
);

Cnpj::isValid();
Cnpj::format();
Cnpj::calculateDv();



vf\Cnpj\Cnpj;

$cnpj = '93.015.006/0001-13';

if (Cnpj::isValid($cnpj)) {
    echo "CNPJ válido";

    echo Cnpj::format(
        Cnpj::removeMask($cnpj)
    );
} else {
    echo "CNPJ inválido";
}

src/
└── Cnpj/
    ├── Cnpj.php
    ├── Validator.php
    ├── Calculator.php
    ├── Converter.php
    └── Formatter.php

A = 10
B = 11
Z = 35