- 博客(27)
- 收藏
- 关注
原创 搭建lnmp--201906
yum安装基础包 yum -y installvim gcc gcc-c++ bison bison-devel zlib-devel libmcrypt-devel mcrypt mhash-devel openssl openssl-devel libxml2-devel libcurl-devel bzip2 bzip2-devel readline-devel libedit-deve...
2019-06-29 11:48:47 812
原创 页面js登录
var refresh = function() { $("#code").attr("src", "/admin/login/captcha");}var login = function() { var username = $('#username').val(); var password = $('#password').val(); var captcha = $('#ca
2017-07-20 11:39:01 524
原创 PHP通配符问题
1,$str = 'Good morning @@name@@ .';$str = str_replace("@@name@@", $name, $str);2,$str = 'What is @@a@@ , @@b@@';$paramsData = [ 'a' => '1', 'b' => '2',];$resultStr = preg_replace_call...
2017-06-21 11:05:22 1112
原创 php读txt
$fp = fopen('test.txt', "r");flock($fp, LOCK_EX);while (($a = fgets($fp)) !== false) { echo "<pre>"; var_dump($a); echo "</pre>";}flock($fp, LOCK_UN);fclose($fp);
2017-05-25 15:09:58 274
原创 mysql相关
1,查询表的索引show index from table_name;备注:Table =>表名Non_unique =>如果索引不能包括重复词,则为0。如果可以,则为1Key_name =>索引名Seq_in_index =>索引中的列序列号,从1开始Column_name =>列名Collation =>列以什么方式存储在索...
2017-05-19 09:28:31 214
原创 php导出excel出现的问题
set_time_limit(300);ini_set('memory_limit','1024M');$objectPHPExcel->getActiveSheet()->setCellValue('B' . ($n), $value->a);$objectPHPExcel->getActiveSheet()->setCellValueExplici...
2017-05-16 19:36:15 363
原创 mysql时间函数
select count(*) from table where create_time > UNIX_TIMESTAMP('2017-5-16 00:00:00') and create_time <= UNIX_TIMESTAMP('2017-05-17 00:00:00');
2017-05-16 17:37:44 237
原创 yii事务
$transaction = \Yii::$app->db->beginTransaction();if () { $transaction->rollBack();} else { $transaction->commit();}数据库引擎为InnoDB才支持事务
2017-04-28 15:57:18 311
原创 php数组根据某值排序(array_multisort)
$a = [ [ 'name' => '张三', 'score' => 60 ], [ 'name' => '李四', 'score' => 90 ], [ 'name' => '王二', 'score' => 80 ...
2017-04-20 12:50:21 3245
原创 mysql字符串拼接
1,CONCAT(string1,string2,…)如果有null,则全是null...CONCAT(IFNULL(string1,''),IFNULL(string2,''),...)即可处理2,CONCAT_WS(separator,str1,str2,...)没有上述null 的问题,separator就是分隔符...
2017-04-13 17:11:36 235
原创 php7的变化
移除了$GLOBALS["HTTP_RAW_POST_DATA"]现在使用$data = file_get_contents("php://input");
2017-04-06 17:37:05 256
原创 php创建一个对象??
$a = new stdClass();echo "<pre>";var_dump(json_encode($a));echo "</pre>";exit;$a = new stdClass();$a->id = 'id';$a->name = 'name';$b = ['id' => 'id','name' =>...
2017-03-31 11:24:03 5785
原创 时间戳转换为天时分秒
$result = ''; if ($secs >= 86400) { $days = floor($secs / 86400); $secs = $secs % 86400; $result = $days . ' 天'; if ($secs > 0) { ...
2017-03-28 14:30:22 5183
原创 apache配置图片路径指向
<IfModule alias_module> Alias /uploads "K:/www/test/backend/web/uploads" <Directory "K:/www/test/backend/web/uploads"> Order allow,deny Allow from all Require all...
2017-03-22 11:40:25 1550
原创 mysql查重笔记
select count(*) as count, mobile from user group by mobile having count > 1;
2017-03-20 20:50:28 962
原创 php去掉表情
private function filterEmoji($str){ $str = preg_replace_callback( '/./u', function (array $match) { return strlen($match[0]) >= 4 ? '' : $match[0]; ...
2017-01-17 16:53:33 414
原创 php判断请求来源
$a = $_SERVER['HTTP_USER_AGENT'];if (strpos($a, 'iPhone') || strpos($a, 'iPad')) {echo '你是苹果';} elseif (strpos($a, 'Android')) {echo '你是安卓';} else {echo '不是苹果也不是安卓';}//感觉挺酷的...
2017-01-16 14:19:51 3411
原创 mysql查询排名的方法(yii的写法)
方法一,举例:查询用户表中id=2的用户创建时间的排名:select count(*) as rank from `user` where create_time <= (select create_time from `user` where id = 2);yii写法:$subQuery = self::find()->select("create_time")...
2017-01-13 09:32:16 467
原创 yii2.0 mysql 函数的使用
use yii\db\Expression;$arQuery = self::find() ->select(['*', new Expression('count(*) as count'), new Expression('FROM_UNIXTIME(create_time,"%Y年%m月%d日") as day')]);$arQuery-&g...
2017-01-13 09:23:10 2502
转载 PHP计算当前坐标3公里内4个角落的最大最小经纬度实例???
//$lng 、$lat 经纬度 $half = 6371; $distance = 3; //3公里 $dlng = 2 * asin(sin($distance / (2 * $half)) / cos(deg2rad($lat))); $dlng = rad2deg($dlng); $dlat = $distance / $half; $dl...
2016-12-30 11:58:13 784
原创 mysql导入导出数据库(表)结构/数据
1,导出dbname库所有表结构mysqldump -uroot -ppasswd -d dbname >db.sql;2,导出dbname库test表结构mysqldump -uroot -ppasswd -d dbname test>db.sql;3,导出dbname库结构和数据mysqldump -uroot -ppasswd dbname &g...
2016-12-12 10:21:33 485
原创 PHP导入excel方法
$filePath = $_FILES['file']['tmp_name']; if(!$filePath){ echo '请选择导入文件!'; exit; } // 要读取的文件的路径 //$phpexcel = new \PHPExcel; ...
2016-12-01 16:22:40 248
原创 PHP导出excel方法
$mModel= new Model(); $list = $mModel->getList(); $objectPHPExcel = new \PHPExcel(); $objectPHPExcel->setActiveSheetIndex(0); //报表头的输出 $objectPHPE...
2016-12-01 16:20:45 301
原创 PHP根据图片url下载图片到本地的两种方法
方法一:file_put_contents(Yii::getAlias('@backend/web/upload/123.jpg'), file_get_contents('https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket=alkshduhalskfjasd));方法二:$url = 'https://mp.weixin.qq.com...
2016-12-01 15:58:51 10666
原创 关于PHP项目初学
<?phpsession_start();define("APP_NAME",dirname(__FILE__).'../App');define("VIEW_NAME",dirname(__FILE__).'../View');include(dirname(__FILE__).'../Includes/mysql.php');include(dirname(__FILE__)....
2015-09-07 20:53:39 217
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人