info about link
: Javascript : PHP Index : MySQL :
isbn check
: Source : : Explanation : : Example : : Todo : : Feedback :

Fill in an isbn number below to check if it's valid.
The check is done by the function (not the class) shown on the source page


Unfortunately, the server on which this website is hosted doesn't support the PHP version necessary for Zend Framework, so i won't be able to give a live demonstration of the Excudo_Validate_ISBN class. But here is a code example anyways:

<?php
// this file contains the Excudo_Validate_Isbn classs
require_once "Excudo/Validate/Isbn.php";

$isbns = array(
    
"1",
    
"978905451584",
    
"9789054515845",
    
"97890545158456",
    
"9789054515844",
    );
$Validator = new Excudo_Validate_Isbn();
foreach (
$isbns AS $isbn)
{
    
$bool $Validator->isValid($isbn);

    if (
$bool)
    {
        echo 
"<span style=\"color: green; font-weight: bold;\">".$isbn."</span> is a valid isbn number<br>\n";
    }
    else
    {
        echo 
"<span style=\"color: red;\">Error:</span> ".end($Validator->getMessages())."<br>\n";
    }
}
?>

This will produce the following output:

Error: '1' does not appear to have a valid length
Error: '978905451584' does not appear to have a valid length
9789054515845 is a valid isbn number
Error: '97890545158456' does not appear to have a valid length
Error: '9789054515844' is not a valid isbn number

=[Disclaimer]=     © 2005-2012 Excudo.net