2008年4月29日
[CODE_LITE]function setCookie(name,value)
{
var Days = 30;
var exp = new Date(); //new Date("December 31, 9998");
exp.setTime(exp.getTime() + Days*24*60*60*1000);
document.cookie = name + "="+ escape (value) + ";expires=" + exp.toGMTString();
...
2008年4月25日
in_array
in_array -- 检查数组中是否存在某个值
说明
bool in_array ( mixed needle, array haystack [, bool strict] )
在 haystack 中搜索 needle,如果找到则返回 TRUE,否则返回 FALSE。
[CODE_LITE]function in_array(needle, haystack) {
if(typeof needle == 'string' || typeof needle == 'number') {
...
2008年4月25日
/*
可用于用户名等不允许使用出现中文字符的地方
itlearner整理发布
*/
$str = "dd*(*d";
if (iscn($str)) {
echo "包括中文的字符串";
} else {
echo "不包括中文的字符串";
}
function iscn($str){
if (preg_match("/.*[".chr(0xa1)."-".chr(0xff)."]+.*/", $str)) {
return true;
} else {
return false;
...
2008年4月24日
JSON一种轻量级的数据格式,由一位资深的软件工程师Douglas Crockford开发,全称为Javascript Object Notation。中文翻译为“JavaScript对象表示”,这个格式的数据可以很容易的被转换为javascript对象的格式,用于服务器端和客户端的数据传递,用于解决xml的过多冗余标签造成数据传输量过大的问题。
JSON-PHP是一个自动完成JSON编码和解码的php开源代码工具。
下载:
json.rar...
2008年4月22日
<SCRIPT LANGUAGE="JavaScript">
<!--
function formatFloat(src, pos)
{
return Math.round(src*Math.pow(10, pos))/Math.pow(10, pos);
}
alert(formatFloat("1212.2323", 2));
//-->
</SCRIPT>
还有如下几种方法:
[CODE_LITE]var test=88888.234;
...
2008年4月17日
/*
采集截取函数,主要用于分析采集的内容
Author: hx
getcon - 截取后去掉html字符,并去掉空格
getcon2 - 单纯截取,直接返回截取内容。
参数:
$par可接受两种格式:
1.前面字符{DATA}后面字符
2.正则表达式
*/
2008年4月14日
/*
* 用于utf8编码的字符串截取
* itlearner注释
*/
function utf8_substr($str,$position,$length)
Tags:
2008年4月14日
[CODE_LITE]
/*
* 用于UTF8编码的程序
* 获得字符串的长度,一个中文表示3个长度
* itlearner编写
*/
function utf8_strlen($str) {
$count = 0;
for($i = 0; $i < strlen($str); $i++){
$value = ord($str[$i]);
if($value > 127) {
$count++;
if($value >= 192 && $value <= 223) $i++;
...
2008年4月11日
传统办法:在标签内加属性 代码多,修改难
<a href="link1.htm" onfocus="this.blur()">link1</a>
<a href="link1.htm" onfocus="this.close()">link1</a>
<a href="link1.htm" hidefocus="true">link1</a>
<a href="link1.htm" hidefocus="hidefocus">link1</a>
2008年4月2日
Discuz用的一个基本函数。
[CODE_LITE]function daddslashes($string, $force = 0) {
if(!$GLOBALS['magic_quotes_gpc'] || $force) {
if(is_array($string)) {
foreach($string as $key => $val) {
$string[$key] = daddslashes($val, $force);
}
} else {
$string = addslashes($string);
...