Class in PHP to work with CPF
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.

The Cpf class

A CPF number is called a Cadastro de Pessoa Física or translated “Registration of a Physical Person” and with this class you can apply the validation of this number in your application and display its formatted value.


CPF number valid, the following code uses a hypothetical number

$cpf = new Cpf('06115058511');
$cpf->valid(); // true
$cpf->format(); // 061.150.585-11

You can set CPF number ignoring the digits from zero to left


You can set CPF number formatted


CPF number invalid

$cpf = new Cpf('21601543695'); 
$cpf->valid(); // false
$cpf->format(); // NULL