动网论坛,站长建站首选,国内使用量最多的论坛软件 动网论坛官方技术讨论区 站长工具 申请属于您自己的免费论坛
首页 | 新闻资讯 | 网站运营 | 网络编程 | 数据库 | 服务器 | 网页设计 | 图像媒体 | 网络应用 | 搜索优化 | 资源下载 | 动网主机 | DVBOX
    本站内  互联网 ASP论坛  ASP.Net论坛  PHP论坛
  
   PHP → 阅读文章

 检查ISBN号码是否合法

作者来源: 
阅读 数 365 人次 , 2006-3-29 4:08:00 


[程序语言] php

[源码来源] http://px.sklar.com
[功能描述] 检查用户输入的isbn号码(可以带也可以不带连字符号)是否合法。

源代码如下:

<?php
/*
* check to see if the entered isbn is valid and return
* true or false depending.
* i'm not even going to try to claim copyright for such
* a simple thing. do what you will with it.
* 8-) keith nunn, kapn@anglican.ca
*/
function checkisbn($isbn) {
$isbn10 = ereg_replace("[^0-9x]","",$isbn);
$checkdigit = 11 - ( ( 10 * substr($isbn10,0,1) + 9 * substr($isbn10,1,1) + 8 * substr($isbn10,2,1) + 7 * substr($isbn10,3,1) + 6 * substr($isbn10,4,1) + 5 * substr($isbn10,5,1) + 4 * substr($isbn10,6,1) + 3 * substr($isbn10,7,1) + 2 * substr($isbn10,8,1) ) % 11);
if ( $checkdigit == 10 ) $checkdigit = "x";
if ( $checkdigit == 11 ) $checkdigit = 0;
if ( $checkdigit == substr($isbn10,9,1) ) {
return true;
}
else {
return false;
}
}
?>

 
 收藏本文  打印本文  论坛讨论  关闭窗口
· 上一篇:用PHP实现文件上传二法
· 下一篇:class.rFastTemplate.php
· 类的自动加载 -- Classes and Objects in PHP5
· Pattern Modifiers - 规则表达式的修饰符
· 不用GD库生成当前时间的PNG格式图象的程序
· mysql的用户变量
· PHP 选项及相关信息函数库


关于本站 | 联系我们 | 业务合作 | 客户案例 | 诚聘英才 | 广告合作 | 收藏本站
海口动网先锋网络科技有限公司版权所有
Copyright © 2000 - 2006 Cndw.Com
中华人民共和国电信与信息服务业务经营许可证编号 琼 ICP 020077