PHP函数
curl get post请求封装函数示例
get请求函数封装function getUrl($url, $header = []) { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_HTTPGET, true); if ($header) { curl_setopt($ch, CURLOPT_HTTPHEADER, $hea...
Zip压缩文件夹php打包函数代码
分享一个我的站长站自用的Zip压缩文件夹php打包函数代码,Zip相关函数是PHP的扩展功能,此函数可以直接复制使用。以下是代码:<?php# 将文件夹的文件压缩到文件里class Zip{ /** * 将目标文件夹下的内容压缩到zip中(zip包含文件夹目录) * @param $s...
正则表达式或filter_var判断网址URL是否合法
正则表达式<?phpfunction is_url($url){$r = "/http[s]?:\/\/[\w.]+[\w\/]*[\w.]*\??[\w=&\+\%]*/is";if(preg_match($r,$url)){//return true;echo '正确的 url 地址';}else{//return false;echo '不是合法的 url 地址';...
php随机生成大小写字符串函数
字符串函数方法function createRandomStr($length){$str = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';//62个字符$strlen = 62;while($length > $strlen){$str .= $str;$strlen += 62;}$str = str_shuffle($str);r...
file_get_contents函数访问大文件超时解决方法
file_get_contents函数在访问大文件时,会报错504超时,下面分享下我的站长站的解决方法。$opts = array('http'=>array('method'=>"GET",'timeout'=>60,)); $context = stream_context_create($opts); $html =file_get_content...
