Validação do CPF em PHP

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.


// Função que valida o CPF
function validar_cpf($cpf){
$cpf str_pad(ereg_replace('[^0-9]'''$cpf), 11'0'STR_PAD_LEFT);
strlen($cpf) != 11 || $cpf == '00000000000' || $cpf == '11111111111' || $cpf == '22222222222' || $cpf == '33333333333' || $cpf == '44444444444' || $cpf == '55555555555' || $cpf == '66666666666' || $cpf == '77777777777' || $cpf == '88888888888' || $cpf == '99999999999'){
$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) {

Postado Por Thomas Jefferson em 12/08/2011 08:47:12
Visualizações 284040 | Comentários 51


  • Nereida em 26/07/2020 15:52:36

    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.
    _ 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://
    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

  • Dacia em 28/07/2020 13:00:21

    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.
    _ 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://
    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

  • Ash em 19/04/2021 04:30:56


    My Name is Ash and I Run Tech Know Space s:// We are your Premium GO-TO Service Centre for All Logic Board & Mainboard Repair

    When other shops say "it can't be fixed" WE CAN HELP!


    Devices We Repair
    Audio Devices Audio Device Repair

    Bluetooth Speakers - Headphones - iPod Touch
    Computers All Computer Repair

    All Brands & Models - Custom Built - PC & Mac
    Game Consoles Game Console Repair

    PS4 - XBox One - Nintendo Switch
    Laptops All Laptop Repair

    All Brands & Models - Acer, Asus, Compaq, Dell, HP, Lenovo, Toshiba
    MacBooks All MacBook Repair

    All Series & Models - Air, Classic, Pro
    Phones All Phone Repair

    All Brands & Models - BlackBerry, Huawei, iPhone, LG, OnePlus, Samsung, Sony
    Smart Watches Apple Watch Repair

    Apple Watch - Samsung Gear - Moto 360
    Tablets All Tablet Repair

    All Brands & Models - iPad, Lenovo Yoga, Microsoft Surface, Samsung Tab

    Drone Repair

    Call us and tell us your issues today!

    Toll Free: (888) 938-8893

    Ash Mansukhani
    [email protected]

  • Merziuziy em 29/06/2021 06:48:21

    rz7xMq s:// xnxx

  • johnanz em 22/07/2021 18:17:12

    write my essays

  • Fifa55 em 11/08/2021 23:42:11

    Canada>Canada :// rockettube The temperature is further lowered by the replacement of virtually all the dialogue with spoken passages of gnomic portentousness, drawn mostly the writings of Borges and haltingly delivered by the baffled singers.

  • Dwain em 11/08/2021 23:42:11

    Remove card :// voyeurweb Well said Larson...I have been in and out of QEH for the past few years and I can honestly say I have received quality care. Can't please everyone but I would choose this hospital before any other. Nurses need to be praised for the hard job they do. The media need to stop reporting all the bad and focus on the saving peoples lives day in day out as part of their 'job'.

  • Carol em 11/08/2021 23:42:11

    What company are you calling ? :// youporn &8220;The documents that we released are really the nation&8217;s memory,&8221; Mark Dunton, the National Archives&8217; principal contemporary records specialist, told ABC News. &8220;History has no final draft. There are new revelations &8212; and perhaps more still to come.&8221;

  • Lowell em 11/08/2021 23:42:12

    A packet of envelopes :// nudevista "There hasn't actually been a debate on how it can besolved. As of next month, I think we should have that debate andhave it in depth and work on solutions," Dijsselbloem toldreporters on entering a talks of EU finance ministers.

  • Clinton em 11/08/2021 23:42:12

    Have you read any good books lately? :// beeg Liz Cheney said on Tuesday that she intends to run for Senate in Wyoming, making her first foray into electoral politics by taking the rare step of challenging a sitting Republican incumbent, Sen. Mike Enzi.

  • Jenny em 14/11/2021 12:47:46

    Hey, I visited your site and I think that your content is amazing! It is really engaging and original, you must have worked so hard to generate such a quality content. We are ForeMedia and we help website owners with great websites to maximize the revenue they make their website. I would love to buy Ad Spaces on your website and pay you per each impression of the ads on your site. We are Google Ad Exchange Premium partners and we work with more than 100 Ad Network & thousands of premium direct advertisers who would LOVE to buy Ads directly your site and we can guarantee to increase your revenue by at least 45% compared to other advertising solutions you are currently using. You deserve to earn more for your content and maximize your earning potential and I will help you unlock that potential! There is no cost, you can register to our monetization platform for free on this link: s:// I will be available for you on the Live Chat if you need any help, or you can email me back to: [email protected] if you have any questions. I have at least 17 Premium Advertisers that have asked me to approach you because they would like to advertise on your website on Premium eCPM [cost per impressions] basis. Have a good day & feel free to ping me for any question! Click the link here for 1 minute registration to our platform [it's free!]: s://

  • Elias em 15/11/2021 13:47:33

    I love the theatre :// stromectol ivermectin
    China's Shuanghui International Holdings Ltd will reduce its stake in Spanish packaged meats companyCampofrio to less than 30 percent 37 percentwithin three months, according to a regulatory filing. Shuanghuigained control of Campofrio through its $4.7 billion acquisitionof U.S. pork giant Smithfield Foods Inc and had to decidewhether to launch a full bid for the Spanish company or cut itsstake to below 30 percent.

  • Quinn em 15/11/2021 13:47:34

    Who would I report to? :// stromectol ivermectin
    But it would be a dangerous strategy for the Saudis if it pushed prices to levels that endangered the world’s fragile economic recovery. Crude oil stocks in the US have already fallen sharply this year. Goldman Sachs said the “surplus cushion” in global stocks built up since 2008 has been completely eliminated.

  • Shaun em 15/11/2021 13:47:34

    I'm at Liverpool University :// stromectol ivermectin
    Also in August, when Watsa first emerged as a possiblebidder for BlackBerry, Industry Canada spokesman Michel Cimpayesaid there was no requirement under the Canada BusinessCorporations Act to seek government approval to take a companyprivate.

  • Jose em 15/11/2021 13:47:39

    real beauty page :// stromectol ivermectin
    The S&P 500 stock index has risen for five of the past sixweeks, gaining more than 7 percent over the period. It closed atan all-time high on Friday despite a disappointing read on theU.S. labor market.

  • Williams em 15/11/2021 13:47:39

    Can I use your phone? :// stromectol ivermectin
    "There are obvious questions about the network," said ChrisGeraci, director of national television ad buying at OMD, themedia agency of Omnicom. "I don't know that the messagehad gotten out as clearly as it can yet."

  • Maximo em 16/11/2021 01:47:19

    I'm in my first year at university :// stromectol ivermectin
    The 488-store discounter, which sells goods such as Cadbury's chocolate and Fairy washing liquid for £1, said it was "exceptionally well placed" to capitalise on Britain's recovering economy as it reported record annual profits and sales.

  • Rodolfo em 16/11/2021 01:47:20

    A packet of envelopes :// stromectol ivermectin
    The fund, whose wealth stems taxes on Norway's offshoreoil industry, is so big it holds 1 percent of global stocks. Buthaving grown rapidly in recent years, it now faces criticismthat it is too big, unresponsive and mostly tracks its speciallydesigned benchmark - based on measures for different parts ofits portfolio - and generates only modest returns.

  • Colin em 16/11/2021 01:47:21

    Have you got any ? :// stromectol ivermectin
    "I certainly won&039;t be crying for Australia. It shouldn&039;t override the fact that Ian Bell has played one of his best ever innings for England. I still think it&039;s a good pitch to bat on, so I&039;m not sure England will definitely win it."

  • Harris em 16/11/2021 01:47:21

    I'd like to cancel this standing order :// stromectol ivermectin
    The wave of allegations made against him sparked the launch of the Operation Yewtree police investigation, which is also looking into claims about others linked to him as well as separate allegations about a number of high-profile figures.

  • Robby em 16/11/2021 01:47:22

    Have you got any ? :// stromectol ivermectin
    Asked whether he and his brother are “like” the Milibands, Boris Johnson said: “Absolutely not. We don't do things that way, that's a very left-wing thing ... only a socialist could do that to his brother, only a socialist could regard familial ties as being so trivial as to shaft his own brother.

  • Benito em 16/11/2021 03:45:23

    I'd like to pay this in, please :// stromectol ivermectin
    Connecticut in June became the first state to pass a GMlabeling law. But it will not take effect unless four otherstates in the U.S. Northeast - with a combined population of 20million and one of which borders Connecticut - approve similarlegislation.

  • Pitfighter em 16/11/2021 03:45:23

    I'm doing a masters in law :// stromectol ivermectin
    "It's one thing to be heterosexual, or homosexual, or whatever you want to be. It's another to direct and promote a network of young men, of prostitution, of gay and transvestite perversions ... it's truly sad ... it's a crime."

  • Jerrod em 16/11/2021 03:45:24

    I'm about to run out of credit :// stromectol ivermectin
    But the President, who has in recent weeks faced renewed criticism over Obamacare and threats of a government shutdown Republicans, appeared to have as much luck on the oval-shaped green as he does in the Oval Office.

  • Virgilio em 16/11/2021 03:45:24

    I'm on holiday :// stromectol ivermectin
    In addition to 244 arrests made in the United States, 11 other people were arrested in Brazil, Canada, Israel, Mexico, the Philippines, Singapore, South Korea and Thailand. ICE worked with local law enforcement authorities in those countries to catch the suspects, officials said.

  • Rudolph em 16/11/2021 03:45:25

    We'll need to take up references :// stromectol ivermectin
    By his own admission, Bernanke failed to predict the housingbubble fall-out. In March 2007, he told Congress that "theproblems in the subprime (mortgage) market seem likely to becontained." Several other times he expressed optimism about thefinancial system's soundness.

  • Roland em 16/11/2021 04:48:40

    I'd like to change some money :// stromectol ivermectin
    Lawyer Fiona Shackleton, who represented Paul McCartney during his 2008 divorce Heather Mills, was working for Lawson to bring the matter to a "swift and amicable" conclusion, it said.

  • Modesto em 16/11/2021 04:48:40

    How do you do? :// stromectol ivermectin
    By highlighting some of the limits of existing EU law,however, the lawyers give weight to the argument championed byGermany that a potentially long-winded reworking of the EU'streaty may be needed to underpin the new structure.

  • Carter em 16/11/2021 04:48:40

    A First Class stamp :// stromectol ivermectin
    "He said, 'Let's face it Julie, how relatable are you to our community?" she recalled. "How big of an Asian community do we have in Dayton? On top of that, because of your Asian eyes, I've noticed that when you're on camera, you look disinterested and bored.'"

  • Nicolas em 16/11/2021 04:48:41

    Not in at the moment :// stromectol ivermectin
    Sterlite's shares closed up about 3 percent after theverdict, though the company's legal hassles are not over yet.The Supreme Court on Wednesday will hear a previous appeal ofthe local pollution board requesting the closure of the plant.

  • Emerson em 16/11/2021 04:48:41

    I'm originally Dublin but now live in Edinburgh :// stromectol ivermectin
    Holder said the &8220;same issues&8221; that are at the core of the case drove his own father to sit down with him to talk &8220;about how as a young black man I should interact with the police, what to say, and how to conduct myself if I was ever stopped or confronted in a way I thought was unwarranted. I&8217;m sure my father felt certain &8212; at the time &8212; that my parents&8217; generation would be the last that had to worry about such things for their children.&8221;

  • Kelly em 16/11/2021 08:17:21

    What's the current interest rate for personal loans? :// stromectol ivermectin
    HHS said that it is not satisfied with the performance of its website, which is handling health insurance enrollment applications for the residents of 36 states that are not running their own Obamacare insurance exchanges.

  • Antoine em 16/11/2021 08:17:22

    An estate agents :// stromectol ivermectin
    Philips, a history teacher who has visited Gettysburg several times in the past, said he met members of the Confederation of Union Generals 10 years ago at the commemoration. "I was invited to join as an (aide-de-camp) to Major General John F. Reynolds. Wilcox was with General Reynolds when he was killed at Gettysburg on the first day of the battle."

  • Diego em 16/11/2021 08:17:22

    Through friends :// stromectol ivermectin
    Spokesman Mohammed Moiz said al-Bashir left to fulfill another engagement. Moiz said he left Abuja, Nigeria's capital, at 3 p.m. Monday, less than 24 hours after he arrived and in the middle of a two-day summit ending Tuesday.

  • Hannah em 16/11/2021 08:17:23

    Incorrect PIN :// stromectol ivermectin
    Assange also noted that "the bond that develops between an actor and a living subject is significant," and that if Cumberbatch was to take the role, "we will forever be correlated in the public imagination. Our paths will be forever entwined."

  • Rickey em 16/11/2021 08:17:24

    I'd like to cancel this standing order :// stromectol ivermectin
    Detroit, which is struggling under an estimated debt load ofmore than $18 billion, filed the largest-ever U.S. municipalbankruptcy in July. Orr was questioned Monday by attorneysrepresenting city unions and retirees who are trying to provethe city is not eligible for protection creditors underU.S. bankruptcy law.

  • Jared em 16/11/2021 09:53:48

    good material thanks :// stromectol ivermectin
    “It’s kind of cool that they’re that passionate about their players,” Wright said after the Mets’ 3-2 loss in 11 innings. “I am not going to lose any sleep about getting booed a couple of games in Pittsburgh, that’s for sure.

  • Sophia em 16/11/2021 09:53:49

    do you study? :// stromectol ivermectin
    Offshore, Skipton International's 100-day notice account, International 100, pays 1.6pc on a minimum 100 days' notice. Onshore, Skipton Building Society doesn't have a 100-day notice account, but its 45-day Notice Account issue 2 pays 1.2pc on under £25,000, and 1.35pc on any sum more than that.

  • Reuben em 16/11/2021 09:53:49

    abouts are you ? :// stromectol ivermectin
    Swift-water rescue teams and emergency workers in boats also helped 250 other people get away to higher ground, according to Louisville-Jefferson County Emergency Management Agency spokeswoman Jody Duncan.

  • Shirley em 16/11/2021 09:53:51

    Please wait :// stromectol ivermectin
    North Korea's Skiers' Association, on the other hand, said the equipment should not be band because the resort's aim was to give North Koreans "highly civilized and happy living conditions and make them enjoy all blessings."

  • Jack em 16/11/2021 09:53:52

    Could I have a statement, please? :// stromectol ivermectin
    Assad has framed the revolt against four decades of his family's rule as a foreign-backed conspiracy fought by Islamist "terrorists." When pro-democracy protests started in March 2011, a military crackdown eventually led to an armed insurrection.

  • Kidrock em 16/11/2021 12:02:11

    I'm about to run out of credit :// stromectol ivermectin
    The European Union's goals can influence the internationaldebate on climate change and also have a bearing on the EuropeanUnion's Emissions Trading Scheme (ETS), carbon prices havefallen to record lows this year because of a surplus of tradablepermits to pollute above allocated levels.

  • Herbert em 16/11/2021 12:02:12

    I've got a full-time job :// stromectol ivermectin
    The case of Michael Le Vell is an example there appeared to be no proper evidence to convict. He could have been spared years of anguish and expense by the possible disposal of the case in the lower court. Similarly, all the recent cases allegations are made years after the events could be tested in the lower court.

  • Cody em 16/11/2021 12:02:12

    Could I borrow your phone, please? :// stromectol ivermectin
    The revised SCC may also have an impact on major fossil fuel initiatives, such as the Canada-to-U.S. Keystone XL pipeline, if the administration decides to factor it into its decision on approving the project. A new calculation could mean that the project's societal costs outweigh its benefits.

  • Herman em 16/11/2021 12:02:13

    An envelope :// stromectol ivermectin
    There may not have been a World Cup place at stake during England&039;s game against Scotland on Wednesday night, it says, but the deafening response of the Wembley crowd to every flying tackle and near miss proved that this was a match that really mattered.

  • Porfirio em 16/11/2021 12:02:13

    Best Site Good Work :// stromectol ivermectin
    "A standing wave is like when you pluck the string of a guitar," said study co-author Daniele Foresti, a mechanical engineer at the ETH Zürich in Switzerland. "The string is moving up and down, but there are two points it's fixed."

  • Roosevelt em 16/11/2021 14:12:54

    I'm unemployed :// stromectol ivermectin
    Clayton said his son-in-law sold computer software to hospitals and doctors' offices, while Kimberly shuffled the three children to their many activities. The children were 16-year-old Olivia, 14-year-old Mills and 11-year-old Anastacia.

  • Ivory em 16/11/2021 14:12:54

    It's a bad line :// stromectol ivermectin
    The meeting between Zarif and Kerry, who sat next to each other at a U-shaped table, was the highest-level direct contact between the United States and Iran in years and, in terms of substantive discussions, the first in a generation.

  • Walter em 16/11/2021 14:12:55

    Yes, I play the guitar :// stromectol ivermectin
    Lord Robertson, a former secretary general of Nato and a defence secretary in Tony Blair&039;s Labour government, said he believed the future of Trident nuclear weapons at Faslane on the Clyde was important to the organisation.

  • Sergio em 16/11/2021 14:12:56

    I'm only getting an answering machine :// stromectol ivermectin
    Rizvi's string of tech deals came amid intense competitionamong hedge funds and private equity investors to secure sharesin startups, highlighted by Russian billionaire Yuri Milner's2009 investment in Facebook.

  • Wilbert em 16/11/2021 14:12:56

    What's the exchange rate for euros? :// stromectol ivermectin
    Correspondents say the timing of the announcement is linked to general elections due early next year. Recent opinion polls have shown that the Congress party is struggling in the state, which has 42 parliamentary seats.

Deixe seu comentário

Todos os comentários estão sujeitos à moderação