PHP code example of ph-7 / eu-vat-validator
1. Go to this page and download the library: Download ph-7/eu-vat-validator 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/ */
ph-7 / eu-vat-validator example snippets
use PH7\Eu\Vat\Validator;
use PH7\Eu\Vat\Provider\Europa;
$oVatValidator = new Validator(new Europa, '0472429986', 'BE');
if ($oVatValidator->check()) {
$sRequestDate = $oVatValidator->getRequestDate();
// Optional, format the date
$sFormattedRequestDate = (new DateTime)->format('d-m-Y');
echo 'Business Name: ' . $oVatValidator->getName() . '<br />';
echo 'Address: ' . $oVatValidator->getAddress() . '<br />';
echo 'Request Date: ' . $sFormattedRequestDate . '<br />';
echo 'Member State: ' . $oVatValidator->getCountryCode() . '<br />';
echo 'VAT Number: ' . $oVatValidator->getVatNumber() . '<br />';
} else {
echo 'Invalid VAT number';
}