PHP code example of nicebooks / isbn

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

    

nicebooks / isbn example snippets


use Nicebooks\Isbn\IsbnTools;
$tools = new IsbnTools();

public function __construct(bool $cleanupBeforeValidate = true, bool $validateCheckDigit = true)

    var_export($tools->isValidIsbn('123456789X')); // true
    var_export($tools->isValidIsbn('9781234567897')); // true
    

    var_export($tools->isValidIsbn10('123456789X')); // true
    

    var_export($tools->isValidIsbn13('9781234567897')); // true
    

    var_export($tools->convertIsbn10to13('123456789X')); // '9781234567897'
    

    var_export($tools->convertIsbn13to10('9781234567897')); // '123456789X'
    

    var_export($formatter->format('123456789X')); // '1-234-56789-X'
    var_export($formatter->format('9781234567897')); // '978-1-234-56789-7'
    

use Nicebooks\Isbn\Isbn;

$isbn = Isbn::of('123456789X'); // will return an instance of Isbn10
$isbn = Isbn::of('9781234567897'); // will return an instance of Isbn13

Isbn10::of('123456789X'); // equivalent to Isbn::of('123456789X')->to10();
Isbn13::of('9781234567897'); // equivalent to Isbn::of('9781234567897')->to13();