用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);
}

随机文章:

1、WordPress分类链接中“category”去掉方法
https://www.onexin.net/wordpress-category-links-in-the-category-remove-method/

2、支持andorid+3D+离线地图Google Maps 5.0
https://www.onexin.net/offline-support-andorid-3-d-map-google-maps-5-0/

3、中秋节快乐!
https://www.onexin.net/happy-moon-festival/

4、正准备安装的 Wordpress 插件
https://www.onexin.net/is-preparing-to-install-wordpress-plug-in/

5、深入理解Magento – 第二章 – Magento请求分发与控制器
https://www.onexin.net/depth-understanding-of-magento-chapter-ii-magento-request-distribution-and-control/

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

Leave a Reply

Your email address will not be published. Required fields are marked *