风火家人开发记要

技术总结精华贴

Category: PHP

PHP, 原创, 服务器, ,

ceontos安装php7.2 提示cURL version 7.10.5 or later is required to compile php with cURL support

centos 安装 php7.2及以上版本的时候还是有几点需要注意的。 不要使用 php.net Download 提供的下载地址,而是使用 git上的下载地址,原因php.net下的里面存在一些bug,一些文件不全,导致无法安装mysqlnd扩展等。类似这种错误: ext/curl/multi.c:501: undefined reference to curl_pushheader_bynum 先安装一些依赖包 sudo yum install -y libxml2-devel sudo yum -y install libcurl-devel sudo yum install openssl openssl-devel sudo yum install bzip2 bzip2-devel sudo yum install freetype-devel sudo yum install libxslt-devel 在运行 ./configure –with-pdo-mysql=mysqlnd –with-mysqli=mysqlnd –enable-fpm –with-curl –with-fd –enable-mbstring 如果 centos7 php7动态编译出现mysqlnd: configure: error: Cannot find OpenSSL’s <evp.h> 错误,显然已经安装了openssl, openssl-devel,为什么还是提示这个错误,搜索了一下evp.h,这个文件也存在。GOOGLE 了一下,在stackoverflow,找到了答案,原来是 phpize 生成的configure脚本有问题。 解决方法: export PHP_OPENSSL_DIR=yes ./configure -with-openssl-dir=/usr/include/openssl –with-pdo-mysql=mysqlnd –with-mysqli=mysqlnd –enable-fpm –with-curl –with-fd –enable-mbstring 以上参数可根据实际情况先不带,后面需要在增加相关扩展。 Ubuntu先编译提示 evp.h的请参考 解决Ubuntu下php 7.0.6 生成 openssl.so报错,configure: error: Cannot find OpenSSLs evp.h。   (646)

查看全文
PHP, 原创, ,

PHPExcel 生成excel并合并单元格

使用Excel模板 第一行定义字段名字 如下 7个字段 demo.xlsx 线路 项目 监测照片数量 实际挑选数量 缺失 可补拍点位 客户名称 数据如下 //整理数组 按 design_no, building_no 合并数据 $need_list_array = array( array( ‘route_name’ => ‘route_name’, ‘building_name’ => ‘building_name’, ‘report_photo_num’ => 1, ‘success_count’ => 1, ‘lost_count’ => 0, ‘position’ => array(11111,222222,333333,44444,555555), ‘design_name’ =>’design_name’, ), array(….) ); 主要代码 包括合并单元格 以上使用的 CI(CodeIgniter)框架 //PHPExcel require_once APPPATH. ‘/third_party/phpexcel/PHPExcel.php’; // Create new PHPExcel object $objPHPExcel = PHPExcel_IOFactory::load(APPPATH.’/resource/demo.xlsx’); $objPHPExcel->setActiveSheetIndex(0); $objActSheet = $objPHPExcel->getActiveSheet(); $base_row = 2; $col_array = array( ‘route_name’ => 0, ‘building_name’ => 1, ‘report_photo_num’ => 2, ‘success_count’ => 3, ‘lost_count’ => 4, ‘position’ => 5, ‘design_name’ => 6, ); //$temp_arr = array(); if( ! empty($need_list_array)) { $key = 0; foreach ($need_list_array as $design_building => $item) { $this_count = count($item[‘position’]); $objActSheet->setCellValueByColumnAndRow($col_array[‘route_name’], $base_row + $key, $item[‘route_name’]); $objActSheet->setCellValueByColumnAndRow($col_array[‘building_name’], $base_row + $key, $item[‘building_name’]); $objActSheet->setCellValueByColumnAndRow($col_array[‘report_photo_num’], $base_row + $key, $item[‘report_photo_num’]); $objActSheet->setCellValueByColumnAndRow($col_array[‘success_count’], $base_row + $key, $item[‘success_count’]); $objActSheet->setCellValueByColumnAndRow($col_array[‘lost_count’], $base_row + $key, $item[‘lost_count’]); foreach ($item[‘position’] as $i => $item_position) { $objActSheet->setCellValueByColumnAndRow($col_array[‘position’], $base_row + $key + $i, $item[‘position’][$i]); } $objActSheet->setCellValueByColumnAndRow($col_array[‘design_name’], $base_row + $key, $item[‘design_name’]); //合并单元格 if($this_count > 1) { $objActSheet->mergeCellsByColumnAndRow($col_array[‘route_name’], $base_row + $key, $col_array[‘route_name’], $base_row + $key + $this_count – 1); $objActSheet->getStyleByColumnAndRow($col_array[‘route_name’], $base_row + $key)->applyFromArray( array( ‘alignment’ => array( /*’horizontal’ => PHPExcel_Style_Alignment::HORIZONTAL_CENTER,*/ ‘vertical’ => PHPExcel_Style_Alignment::VERTICAL_CENTER))); $objActSheet->mergeCellsByColumnAndRow($col_array[‘building_name’], $base_row + $key, $col_array[‘building_name’], $base_row + $key + $this_count –

查看全文