1. Go to this page and download the library: Download jmbg-labs/jmbg library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
$jmbg = new Jmbg('0710003730015');
$age = $jmbg->getAge();
if ($age >= 18) {
echo "Adult";
} else {
echo "Minor";
}
use JmbgLabs\Jmbg\Jmbg;
use JmbgLabs\Jmbg\JmbgException;
try {
$jmbg = new Jmbg('1234567890123');
} catch (JmbgException $e) {
// Handle specific validation errors
echo "Validation failed: " . $e->getMessage();
// Possible messages:
// - "Input string must have 13 digits."
// - "JMBG string must have 13 digits."
// - "Date '...' is not valid."
// - "Region '...' is not valid for Serbian JMBG."
// - "Checksum is not valid."
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.