PHP code example of cds / nhs-number-validation

1. Go to this page and download the library: Download cds/nhs-number-validation 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/ */

    

cds / nhs-number-validation example snippets




// _DIR__ . '/vendor/autoload.php';

// setup our validator
$nhsValidator = new \CloudDataService\NHSNumberValidation\Validator;

// start with our test NHS number (usually taken via user input)
$nhs_no = '401 023 2137';

try {
    $valid_nhs_no = $nhsValidator->valdate($nhs_no);
} catch (\CloudDataService\NHSNumberValidation\InvalidNumberException $e) {
    die($e->getMessage() . PHP_EOL);
}

if (!empty($valid_nhs_no)) {
    print "YAY! {$valid_nhs_no} is a valid NHS Number\r\n";
}