PHP Classes

File: example.php

Recommend this page to a friend!
  Classes of Artur Graniszewski   PESEL validator   example.php   Download  
File: example.php
Role: Example script
Content type: text/plain
Description: Example class
Class: PESEL validator
Validate Polish PESEL numbers
Author: By
Last change: Changed sourcecode formatting
Date: 12 years ago
Size: 969 bytes


Class file image Download
    <style type="text/css">
    body {font-family: tahoma, verdana, arial; font-size: 12px;}


= array(
'02070803628', // valid PESEL number
'02170803628', // invalid PESEL number
'07020803628', // valid PESEL number (checksum is the same as in first example, see PESEL checksum bug on wikipedia)


$pesels as $peselNumber) {
    try {
$pesel = new Pesel($peselNumber);
printf('<strong>PESEL #'.$peselNumber.
' is valid.</strong><br /><br />day of birth: <strong>%s-%s-%s</strong><br />sex: <strong>%s</strong>',
$pesel->getDayOfBirth(), $pesel->getMonthOfBirth(), $pesel->getYearOfBirth(), ($pesel->isMale() ? 'male' : 'female'));
    } catch (
Exception $e) {
'<strong>PESEL #'.htmlspecialchars($peselNumber).' is invalid</strong><br /><br />reason: <strong>'.$e->getMessage().'</strong>';
"<hr />";