精炼的jquery评分代码

[html]
<html>
<head><title>JQuery星星评级</title><meta http-equiv="Content-Type" content="text/html; charset=gbk" />
<script src="http://jqueryjs.googlecode.com/files/jquery-1.2.6.min.js" type="text/javascript"></script>
<style type="text/css">
<!–
.star_rating {background:url(https://www.lvxinwei.com/wp-content/uploads/2012/03/114922_gGrF_101311.gif) -80px 0 no-repeat; padding:0;margin:0; width:80px; height:16px; float:left; position:relative; }
.star_rating li {padding:0;margin:0;float:left;width:16px;height:16px;}
–>
</style>
</head><body>
<div style="display:block; float:left;width:100px;"><span>*</span>&nbsp;总体评价:</div>
<ul class="star_rating"><li><li/><li><li/><li></li><li></li></ul>

<script type="text/javascript">
(‘.star_rating li’).each(function(){ (this).click(function(obj){
(‘.star_rating li’).unbind();//移除事件绑定 var Too = (obj.srcElement.offsetLeft+16); setStarPos(Too-80); alert((Too/16)+’星’); }).mouseover(function(obj){ setStarPos((obj.srcElement.offsetLeft+16)-80); }).mouseout(function(obj){ setStarPos(‘-80’); }); }); function setStarPos(le){ (‘.star_rating’).css({‘backgroundPosition’:le+’px 0′});
};
</script></body></html>
[/html]

PHP Javascipt

Create an array containing the range of integers or characters from low to high (inclusive)
[js]
function range (low, high, step) {
// Create an array containing the range of integers or characters from low to high (inclusive)
//
// version: 1109.2015
// discuss at: http://phpjs.org/functions/range
// + original by: Waldo Malqui Silva
// * example 1: range ( 0, 12 );
// * returns 1: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]
// * example 2: range( 0, 100, 10 );
// * returns 2: [0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100]
// * example 3: range( ‘a’, ‘i’ );
// * returns 3: [‘a’, ‘b’, ‘c’, ‘d’, ‘e’, ‘f’, ‘g’, ‘h’, ‘i’]
// * example 4: range( ‘c’, ‘a’ );
// * returns 4: [‘c’, ‘b’, ‘a’]
var matrix = [];
var inival, endval, plus;
var walker = step || 1;
var chars = false;

if (!isNaN(low) && !isNaN(high)) {
inival = low;
endval = high;
} else if (isNaN(low) && isNaN(high)) {
chars = true;
inival = low.charCodeAt(0);
endval = high.charCodeAt(0);
} else {
inival = (isNaN(low) ? 0 : low);
endval = (isNaN(high) ? 0 : high);
}

plus = ((inival > endval) ? false : true);
if (plus) {
while (inival <= endval) {
matrix.push(((chars) ? String.fromCharCode(inival) : inival));
inival += walker;
}
} else {
while (inival >= endval) {
matrix.push(((chars) ? String.fromCharCode(inival) : inival));
inival -= walker;
}
}

return matrix;
}
[/js]
[js]
function range (low, high) {
// http://phpjs.org/functions/range:499
var matrix = [];
var inival, endval, plus;
var chars = false;

if ( /^d+/.test(low) && /^d+/.test(high) ) {
inival = parseInt(low);
endval = parseInt(high);
} else {
chars = true;
inival = low.charCodeAt(0);
endval = high.charCodeAt(0);
}

plus = (inival > endval) ? false : true;
if (plus) {
while (inival <= endval) {
matrix.push( chars ? String.fromCharCode(inival) : inival );
inival += 1;
}
} else {
while (inival >= endval) {
matrix.push( chars ? String.fromCharCode(inival) : inival );
inival -= 1;
}
}

return matrix;
}
[/js]

PHP定时执行任务

1.不好的方法
[php]
ignore_user_abort();//关掉浏览器,PHP脚本也可以继续执行.
set_time_limit(0);// 通过set_time_limit(0)可以让程序无限制的执行下去
interval=60*30;// 每隔半小时运行 do{ //这里是你要执行的代码 sleep(interval);// 等待5分钟
}while(true);
[/php]
2.借助系统定时任务,使用PHP命令
linux 借助crontab 命令

[shell]
* * * * * /var/php目录/php /var/www/crontab/index.php
//每分钟执行一次crontab 下的index.php
[/shell]