PHP Classes

ISBN check: Validate ISBN-10, ISBN-13 and convert between them

Recommend this page to a friend!
     
  Info   Example   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
StarStarStarStar 67%Total: 1,521 All time: 2,578 This week: 57Up
Version License PHP version Categories
isbncheck 0.3Public Domain5Validation
Description 

Author

This is a simple class to verify whether a given book's ISBN (International Standard Book Number) code is valid. Supports ISBN-10 and ISBN-13 and GTIN-14. Will perform conversions on valid numbers when possible.

Picture of Keith Nunn
  Performance   Level  
Name: Keith Nunn <contact>
Classes: 1 package by
Country: Canada Canada

Example

<?php
   
echo "<html><body>\n";

   
/*
     * include class and create object
     */
   
include_once 'isbntest.class.php';
   
$currISBN = new ISBNtest;

   
/*
     * did we get an ISBN?
     */
   
if ($_REQUEST[isbn]) {
       
$currISBN->set_isbn($_REQUEST[isbn]);
        if (
$currISBN->valid_isbn10() === TRUE) {
            echo
"<p>The ISBN-10 " . $currISBN->get_isbn10() . " is <span style=\"color: green;\">valid</span>.</p>\n";
        } else {
            echo
"<p>The ISBN-10 " . $currISBN->get_isbn10() . " is <span style=\"color: red;\">invalid</span>.</p>\n";
            echo
"<p>The error reported is:<br /> " . $currISBN->get_error() . "</p>\n";
        }
        if (
$currISBN->valid_isbn13() === TRUE) {
            echo
"<p>The ISBN-13 " . $currISBN->get_isbn13() . " is <span style=\"color: green;\">valid</span>.</p>\n";
        } else {
            echo
"<p>The ISBN-13 " . $currISBN->get_isbn13() . " is <span style=\"color: red;\">invalid</span>.</p>\n";
            echo
"<p>The error reported is:<br /> " . $currISBN->get_error() . "</p>\n";
        }
    }

   
/*
     * input form
     */
   
echo "<FORM ACTION=\"" . $PHP_SELF . "\" METHOD=\"get\">\n";
    echo
"<B>isbn</B>\n";
    echo
"<INPUT TYPE=\"Text\" NAME=\"isbn\" SIZE=\"15\" MAXLENGTH=\"15\" VALUE=\"" . $_REQUEST[isbn] . "\">\n";
    echo
"<INPUT TYPE=\"Submit\" NAME=\"submit\" VALUE=\"Submit\">\n";
    echo
"</form>\n";

    echo
"</body></html>\n";

?>


  Files folder image Files (3)  
File Role Description
Accessible without login Plain text file cli_example.php Example just an example to show basic usage.
Accessible without login Plain text file example.php Example an example script showing usage
Plain text file isbntest.class.php Class class that does the ISBN checking

The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page.
Install with Composer Install with Composer
 Version Control Unique User Downloads Download Rankings  
 0%
Total:1,521
This week:0
All time:2,578
This week:57Up
User Ratings User Comments (1)
 All time
Utility:100%StarStarStarStarStarStar
Consistency:83%StarStarStarStarStar
Documentation:-
Examples:91%StarStarStarStarStar
Tests:-
Videos:-
Overall:67%StarStarStarStar
Rank:456
 
Great!
16 years ago (Przemek Czekaj)
70%StarStarStarStar