Home  >  Article  >  Backend Development  >  PHP一句话经典代码 经典业务解决方案

PHP一句话经典代码 经典业务解决方案

WBOY
WBOYOriginal
2016-06-23 13:41:281338browse

1.PHP采集中批量随机模拟客户IP地址

echo join('.', array(mt_rand(0, 255), mt_rand(0, 255), mt_rand(0, 255), mt_rand(0, 255)));


2.Mysql插入时1条inser批量高效插入大数据

$db->query('INSERT INTO `myTable` (`address`) VALUES '.join(',', array_map(function($ip, $port){return '("'.($ip.':'.$port).'")';}, $ipArray[0], $ipArray[1])).';');注意,你的$ipArray数据格式为:$ipArray = array(array('127.0.0.1','192.168.1.1'), array('80','443'));

3.采集时不要让程序太频繁的采集目标站点(防止被目标发现、防止太频繁导致目标站不能正常访问),我们可以采取程序休息的方式:


usleep(mt_rand(1000, 1000000));//单位是微妙



Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn