Função para validação do número do CPF em PHP.
Como todos sabem o cpf é validado através de um cálculo númerico e, como é mais facil fazer q explicar, segue abaixo a função para validação.
Obs.: Vale à pena frizar, para validação de um cpf não é necessário acessar uma base de dados da receita federal e sim efetuar um cálculo matemático para validar a seguencia numérica com o digito verificador. Vale lembrar ainda que a validação do mesmo não garante a total veracidade do número, pois podemos gerar números (se soubermos a regra de validação) que são válidos mas não são existentes.
<?php
// Função que valida o CPF
function validar_cpf($cpf){
$cpf = str_pad(ereg_replace('[^0-9]', '', $cpf), 11, '0', STR_PAD_LEFT);
if(strlen($cpf) != 11 || $cpf == '00000000000' || $cpf == '11111111111' || $cpf == '22222222222' || $cpf == '33333333333' || $cpf == '44444444444' || $cpf == '55555555555' || $cpf == '66666666666' || $cpf == '77777777777' || $cpf == '88888888888' || $cpf == '99999999999'){
return False;
}else{
for($t = 9; $t < 11; $t++){
for ($d = 0, $c = 0; $c < $t; $c++) {
$d += $cpf{$c} * (($t + 1) - $c);
}
$d = ((10 * $d) % 11) % 10;
if ($cpf{$c} != $d) {
return False;
}
}
return True;
}
}
?>
This survival grenade is a mini survival kit designed to help you survive in an emergency
and it_s totally free no joke no market trick.. its free.
Small portable and essential equipment to help you survive those vital first 48 hours of a civil war or unrest.
Included
_ Paracord (9ft)
_ Carabiner
_ Scalpel (2.25in)
_ Alcohol Prep Pad
_ Fishing Hooks (1 sml, 2 lrg)
_ Fishing Floats (2)
_ Fishing Weights (2)
_ Fishing Line
_ Jigs (2)
_ Safety Pins (2)
_ Needle
_ Wire
_ Aluminum Foil (1 sq ft)
_ Ferro Rod Firestarter
_ Tinder
We live in unsettling times, are you prepared?
Check it out for yourself s://.totalfreebie.com/totally-free-survival-grenade/
Normal retail price $14.99
All we are ask for is that you pay the standard postage, the actual product it free of charge.
Shipping within USA is $6.95USD
This survival grenade is a mini survival kit designed to help you survive in an emergency
and it_s totally free no joke no market trick.. its free.
Small portable and essential equipment to help you survive those vital first 48 hours of a civil war or unrest.
Included
_ Paracord (9ft)
_ Carabiner
_ Scalpel (2.25in)
_ Alcohol Prep Pad
_ Fishing Hooks (1 sml, 2 lrg)
_ Fishing Floats (2)
_ Fishing Weights (2)
_ Fishing Line
_ Jigs (2)
_ Safety Pins (2)
_ Needle
_ Wire
_ Aluminum Foil (1 sq ft)
_ Ferro Rod Firestarter
_ Tinder
We live in unsettling times, are you prepared?
Check it out for yourself s://.totalfreebie.com/totally-free-survival-grenade/
Normal retail price $14.99
All we are ask for is that you pay the standard postage, the actual product it free of charge.
Shipping within USA is $6.95USD