随笔分类 - php
摘要:// 冒泡排序 function maopao($arr) { $len = count($arr); for ($i = 0; $i < $len -1; $i++) {//循环对比的轮数 for ($j = 0; $j < $len - $i - 1; $j++) {//当前轮相邻元素循环对比
阅读全文
摘要:left join(左联接) 返回包括左表中的所有记录和右表中联结字段相等的记录 right join(右联接) 返回包括右表中的所有记录和左表中联结字段相等的记录 inner join(等值连接) 只返回两个表中联结字段相等的行
阅读全文
摘要:解决方法 print_r($pdo->errorInfo()); 打印看报什么错,把报错解决就可以
阅读全文
摘要:/** * 只保留字符串首尾字符,隐藏中间用*代替(两个字符时只显示第一个) * @param string $user_name 姓名 * @return string 格式化后的姓名 */ function substr_cut($user_name){ $strlen = mb_strlen(
阅读全文
摘要:/** * 使用$replace替换字符串的中间部分 */ function replaceCenterWithChar($str, $replace = "*", $leftLen = 2, $rightLen = 2, $replaceLen = 3) { $length = mb_strlen
阅读全文
摘要:<?php class test{ function abc(){ return '123'; } } header("Content-type: text/html; charset=utf-8"); $servername = 'localhost'; $username = '*****';
阅读全文
摘要:<body>//方法一 <form action="03-post-file.php" method="post" enctype="multipart/form-data"> <!-- enctype="multipart/form-data" 必须给form表单指定该属性,否则上传不了文件 --
阅读全文
摘要:<?php echo date('Y-m-d H:i:s',strtotime('now'));//当前时间戳 2017-01-09 21:04:11 echo date('Y-m-d H:i:s',strtotime('+1second'));//当前时间戳+1秒 2017-01-09 21:04
阅读全文
摘要:1、使用fetchAll函数 $q = $db->query("SELECT count(*) from db;"); $rows = $q->fetchAll(); $rowCount = count($rows);2、使用sql count函数$q = $db->query("SELECT co
阅读全文
摘要:public function get_shenfen($id){ //截取前两位数 $index = substr($id,0,2); $area = array( 11 => "北京", 12 => "天津", 13 => "河北", 14 => "山西", 15 => "内蒙古", 21 =>
阅读全文