PHP code example of enricky / cpf-manager

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

    

enricky / cpf-manager example snippets



use Enricky\CpfManager\Cpf;

$cpf = Cpf::generate();
echo $cpf; // 147.001.216-29

$cpfValido = Cpf::validate('147.001.216-29');
var_dump($cpfValido); //bool(true)

$cpfInvalido = Cpf::validate('111.111.111-11');
var_dump($cpfInvalido); //bool(false)

$cpfFormatado = Cpf::format('14700121629');
echo $cpfFormatado; // 147.001.216-29

$formatoValido = Cpf::validateFormat('147.001.216-29');
var_dump($formatoValido); //bool(true)

$formatoInvalido = Cpf::validateFormat('147-001-216-29');
var_dump($formatoInvalido); //bool(false)

$cpfLimpo = Cpf::cleanUp('147.001.216-29');
echo $cpfLimpo; // 14700121629