PHP code example of fdt2k / isbn
1. Go to this page and download the library: Download fdt2k/isbn 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/ */
fdt2k / isbn example snippets
use Biblys\Isbn\Isbn;
try {
$input = "9782843449499";
$isbn13 = Isbn::convertToIsbn13($input);
echo "ISBN-13: $isbn13"; // Prints ISBN-13: 978-2-84344-949-9
} catch(Exception $e) {
echo "An error occurred while attempting to format ISBN $input: ".$e->getMessage();
}
use Biblys\Isbn\Isbn;
try {
$input = "978-2-843-44949-9";
Isbn::validateAsIsbn13($input);
echo "ISBN $input is valid!";
} catch(Exception $e) { // Will throw because third hyphen is misplaced
echo "ISBN $input is invalid: ".$e->getMessage();
}
console
PHP_VERSION=7.1 composer docker:test