Location: PHPKode > scripts > PESEL validator > example.php
<html>
<head>
	<title>Example</title>
	<style type="text/css">
	body {font-family: tahoma, verdana, arial; font-size: 12px;}
	</style>
</head>

<?php

$pesels = 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)
);

require_once('pesel.php');

foreach($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) {
		echo '<strong>PESEL #'.htmlspecialchars($peselNumber).' is invalid</strong><br /><br />reason: <strong>'.$e->getMessage().'</strong>'; 
	}
	echo "<hr />";
}
?>

</html>
Return current item: PESEL validator