PHP code example of pilou / eu-vat-id-validation

1. Go to this page and download the library: Download pilou/eu-vat-id-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/ */

    

pilou / eu-vat-id-validation example snippets


Array (
    [vatId] => IT01775560442
    [vatNumber] => 01775560442
    [countryCode] => IT
    [isValid] => 1
    [companyName] => M.A.B. SOFTWARE SRL
    [companyAddress] => C DA CAMPIGLIONE 20 63900 FERMO FM
)

$vatId = new \Pilou\EuVat\Validation('IT01775560442');  
print_r($vatId->isValid());

// Output
true

$vatId = new \Pilou\EuVat\Validation;

$vatId->setVatId('IT01775560442');
print_r($vatId->isValid());             // Output: true

$vatId->setVatId('XX123456789');
print_r($vatId->isValid());             // Output: false

$vatId = new \Pilou\EuVat\Validation('IT01775560442');
print_r($vatId->toArray());

// Output
Array (
    [vatId] => IT01775560442
    [vatNumber] => 01775560442
    [countryCode] => IT
    [isValid] => 1
    [companyName] => M.A.B. SOFTWARE SRL
    [companyAddress] => C DA CAMPIGLIONE 20 63900 FERMO FM
)

$vatId = new \Pilou\EuVat\Validation;
$vatId->setVatId('IT01775560442');
$vatId->validate();

print_r($vatId->isValid());             // Output: true
print_r($vatId->getVatId());            // Output: 'IT01775560442'

print_r($vatId->toArray());

// Output
Array (
    [vatId] => IT01775560442
    [vatNumber] => 01775560442
    [countryCode] => IT
    [isValid] => 1
    [companyName] => M.A.B. SOFTWARE SRL
    [companyAddress] => C DA CAMPIGLIONE 20 63900 FERMO FM
)