This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function validaCPF($cpf) { | |
// Extrai somente os números | |
$cpf = preg_replace( '/[^0-9]/is', '', $cpf ); | |
// Verifica se foi informado todos os digitos corretamente | |
if (strlen($cpf) != 11) { | |
return false; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function validar_cpf($cpf) | |
{ | |
$cpf = preg_replace('/[^0-9]/', '', (string) $cpf); | |
// Valida tamanho | |
if (strlen($cpf) != 11) | |
return false; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function validar_cnpj($cnpj) | |
{ | |
$cnpj = preg_replace('/[^0-9]/', '', (string) $cnpj); | |
// Valida tamanho | |
if (strlen($cnpj) != 14) | |
return false; |