随笔分类 - php
摘要:遍历文件夹中的文件: 1 $handle = opendir($folder_path); 2 while (false !== ($filename = readdir($handle))){ 3 $files[] = $filename; 4 } 5 closedir($handle); 6 v
阅读全文
摘要:判断字符串是否以某字符串结尾的方法 // $str:原字符串,$suffix:子字符串(区分大小写) function endWith($str, $suffix) { $length = strlen($suffix); if ($length == 0) { return true; } ret
阅读全文
摘要:public function get_redirect_url($url){ error_reporting(0); $header = get_headers($url, 1); if (strpos($header[0], '301') !== false || strpos($header[
阅读全文
摘要:1、 $file = 'x.y.z.png'; echo substr(strrchr($file, '.'), 1); strrchr() 函数查找字符串在另一个字符串中最后一次出现的位置,并返回从该位置到字符串结尾的所有字符。 2、 $file = 'x.y.z.png'; echo subst
阅读全文
摘要:先查看自己的php版本,使用 phpinfo() 函数查看 上图红色框中的信息下载扩展的时候需要用到 下载imagemagick程序 下载地址:http://windows.php.net/downloads/pecl/deps/ 下载这个区域里面的对应版本,选择最高版本,根据上图中的信息下载vc1
阅读全文
摘要:在PHP7中已经废除了mysql库了,则只能使用mysqli及PDO mysqli 连接数据库 1、mysqli面向对象编程 <?php $serve = '127.0.0.1:3306'; $username = 'root'; $password = 'root'; $dbname = 'acc
阅读全文
摘要:遇到的问题: 在执行GuzzleHttp时发下错误:Fatal error: Uncaught GuzzleHttp\Exception\RequestException: cURL error 60: SSL certificate problem: unable to get local iss
阅读全文
摘要:preg_match("/<div class=\"m4_box6\".*?>.*?<\/div>/ism",$newhtml,$matchs2);
阅读全文
摘要:仿站的时候采集到的数据存在很多可以跳转其他站的a链接,在采集的时候就可以替换掉 <?php // 替换a标签中的href属性值 function a_replace_href($str) { $preg = '/href=(\"|\')(.*?)(\"|\')/i'; $replacestr = '
阅读全文
摘要:1、不以 "hello" 开头 /^(?!hello.*)/ 2、不以 "(hello)" 开头 /^(?![\(\(]hello[\)\)]).*/ 注:^是字符串开头,(?! ) 是正向否定预查,简单说,以 xxx(?!pattern)为例,就是捕获不以pattern结尾的内容xxx php 去
阅读全文