用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、PHPCMS v9 在php7.x下整合UC通信失败
https://www.onexin.net/phpcms-v9-php7x-uc/

2、DIV与Table布局在大型网站的可用性比较
https://www.onexin.net/div-and-table-layout-of-the-availability-of-large-sites/

3、Facebook Api 开发者使用(PHP版)
https://www.onexin.net/facebook-api-developers-use-php-version/

4、Adidas Epic
https://www.onexin.net/adidas-epic/

5、认清CSS的类class和标识id选择符
https://www.onexin.net/a-clear-understanding-of-the-css-class-of-class-and-identity-id-selector/

Leave a Reply