用js实现sleep, 用php实现parseInt

用js实现sleep:

//使用方法:
sleep(3);
//sleep
function sleep(numberMillis) {
    var now = new Date();
    var exitTime = now.getTime() + numberMillis;
    while (true) {
        now = new Date();
        if (now.getTime() > exitTime)
            return;
    }
}

用php实现parseInt

//使用方法:
parseInt('08', 16); //8
parseInt('0F', 16); //15
parseInt('12', 16); //18
parseInt('AB', 16); //171
//parseInt
function parseInt($string, $radix = '0') {
	if(is_array($string)) {
		foreach($string as $key => $val) {
			$res[$key] = parseInt($val, $radix);
		}
	}else{
		$res = intval($string, $radix);
	}
	return (int)($res);
}

转载请注明出处:https://www.onexin.net/use-js-to-achieve-sleep-use-php-to-achieve-parseint/

随机文章:

1、网站显示谷歌纵横widget
https://www.onexin.net/latitude-widget-site-to-show-google/

2、图片防盗链代码
https://www.onexin.net/picture-anti-daolian-code/

3、Discuz!Q 升级 v2.3.210202 版本后,进行红蓝主题切换时报错 Warning: shell_exec() has been disabled for security reasons in 如何解决?
https://www.onexin.net/discuzq-v2-3-210202-warning-shell_exec-ha/

4、为什么PHP中GET值乱码?
https://www.onexin.net/why-php-get-values-in-garbled/

5、正则表达式匹配数据的实例应用
https://www.onexin.net/regular-expression/

Leave a Reply