PHP小结大全

CURL设置超时

  1. curl普通秒级超时:
$ch = curl_init();       
curl_setopt($ch, CURLOPT_URL,$url);     
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);        
curl_setopt($ch, CURLOPT_TIMEOUT,60);   //只需要设置一个秒的数量就可以   
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);        
curl_setopt($ch, CURLOPT_USERAGENT, $defined_vars['HTTP_USER_AGENT']);
  1. curl普通秒级超时使用:
    复制代码代码如下:
curl_setopt($ch, CURLOPT_TIMEOUT,60);
  1. curl如果需要进行毫秒超时,需要增加:
    复制代码代码如下:
curl_easy_setopt(curl, CURLOPT_NOSIGNAL,1L);       //或者       
curl_setopt ( $ch,  CURLOPT_NOSIGNAL,true);//支持毫秒级别超时设置

explore 和implore

两个不错的函数,字符串拆分和合并

sql注入解析

 function filterWords(&$str)
    {
        $farr = array(
            "/<(\\/?)(script|i?frame|style|html|body|title|link|meta|object|\\?|\\%)([^>]*?)>/isU",
            "/(<[^>]*)on[a-zA-Z]+\s*=([^>]*>)/isU",
            "/select\b|insert\b|update\b|delete\b|drop\b|;|\"|\'|\/\*|\*|\.\.\/|\.\/|union|into|load_file|outfile|dump/is"
        );
        $str = preg_replace($farr,'',$str);
        $str = strip_tags($str);
        return $str;
    }

你可能感兴趣的:(PHP小结大全)