随笔分类 -  开发经验杂谈

记录一些开发过程遇到的问题
摘要:现有a.php 和 b.php在同一个目录下 a.php中 namespace myspace; class A{ __construct(){} .... } b.php中调用类A require_once('./a.php '); $obj = new \myspace\A(); 阅读全文
posted @ 2018-03-09 16:09 AlanLeung 阅读(2065) 评论(0) 推荐(0)
摘要:1. 值为null的字段,假如update table set a=a+1,则会报sql错误 2. //todo 阅读全文
posted @ 2018-03-05 17:25 AlanLeung 阅读(146) 评论(0) 推荐(0)
摘要:1. 在ajax的任何回调方法中,比如success回调,使用return,将会无效 2. //todo 阅读全文
posted @ 2018-03-05 17:19 AlanLeung 阅读(133) 评论(0) 推荐(0)
摘要:1. 在<form><form/>标签里面的<button>标签要设置type="button",否则可能会在点击按钮时自动提交这个表单 2. //todo 阅读全文
posted @ 2018-03-05 17:14 AlanLeung 阅读(208) 评论(0) 推荐(0)
摘要:TinkPHP5中 1. model中select()后的查询结果是对象而不是数组 2. model中 假如有 $result=$this->field($fields)->where($condition)->order("id desc")->page($limit)->select(); 如果 阅读全文
posted @ 2018-03-05 17:12 AlanLeung 阅读(148) 评论(0) 推荐(0)
摘要:string mb_substr ( string $str , int $start [, int $length = NULL [, string $encoding = mb_internal_encoding() ]] ) 根据字符数执行一个多字节安全的 substr() 操作。 位置是从  阅读全文
posted @ 2018-03-05 16:59 AlanLeung 阅读(410) 评论(0) 推荐(0)
摘要:跨域名的接口:A域名www.a.com请求B域名www.b.com的接口(域名可以换成ip地址,同样成立) 非跨域接口:A域名www.a.com请求A域名www.a.com的接口 对于跨域名的接口请求: 1. 如果是前端js请求,则需要使用AJAX+JSONP 2. 后端PHP请求可以用WebSer 阅读全文
posted @ 2018-03-05 16:50 AlanLeung 阅读(319) 评论(0) 推荐(0)
摘要:var reg = /^((0\d{2,3}-\d{7,8})|(1[34578]\d{9}))$/; //校验手机号和固定电话 if ( !reg.test(shop_tel) || check_empty(shop_tel) ){ return alert("请输入正确的手机号"); } 阅读全文
posted @ 2018-03-05 16:42 AlanLeung 阅读(6772) 评论(2) 推荐(0)
摘要:当统计一个有重复的字段可以用这个方法 $count = $model->where($map)->count('distinct(id)'); 转自 http://www.thinkphp.cn/code/185.html 阅读全文
posted @ 2018-03-05 16:38 AlanLeung 阅读(256) 评论(0) 推荐(0)
摘要:简单的增删改查放到BaseModel,复杂查询放到新建的model,这个新的model继承BaseModel 阅读全文
posted @ 2017-09-27 16:36 AlanLeung 阅读(157) 评论(0) 推荐(0)
摘要:转自:http://www.jb51.net/article/75717.htm 阅读全文
posted @ 2017-09-27 16:29 AlanLeung 阅读(190) 评论(0) 推荐(0)
摘要:是变量名和函数名相同导致的 比如: function a(){} var a = a(); 阅读全文
posted @ 2017-09-27 16:24 AlanLeung 阅读(766) 评论(0) 推荐(0)
摘要:html的js或者css超过30行时,应当将js或css分离到外部文件,然后引入到html文件。 阅读全文
posted @ 2017-09-27 16:13 AlanLeung 阅读(174) 评论(0) 推荐(0)
摘要:对小数进行处理: 1.直接取整,舍弃小数,保留整数:intval(); intval(3.64159); // 3 2.四舍五入取整:round(); round(3.14159); // 3 round(3.64159); // 43.向上取整,有小数就加1:ceil(); ceil(3.1415 阅读全文
posted @ 2017-08-23 10:43 AlanLeung 阅读(6562) 评论(0) 推荐(0)
摘要:先上代码(php): $id_card=""; $sql = "select * from people where id_card=".$id_card; 看似有值,但是这个sql是这样的: select * from people where id_card= 当然会语法错误。 这时候要把$id 阅读全文
posted @ 2017-08-22 15:44 AlanLeung 阅读(846) 评论(0) 推荐(0)
摘要:find方法返回的是一行记录,结果是一个数组,数组的key和sql中的field相对应,假设: $res=$model->find(filed="a,b,c"); 获取结果中的a的值用: $res["a"] 阅读全文
posted @ 2017-08-22 15:38 AlanLeung 阅读(4045) 评论(0) 推荐(0)
摘要:原因是没有连接数据库。加上下面代码: $link = mysql_connect(DB_HOST,DB_USER,DB_PWD);mysql_select_db(DB_NAME) or die('Could not select database'); 业务全部完毕后记得手动关闭连接: <?php 阅读全文
posted @ 2017-08-22 15:34 AlanLeung 阅读(1282) 评论(0) 推荐(0)
摘要:先上代码 讨论的是async这个条件,一般情况下都是false表示同步,但是遇到要加载的信息量非常多的时候,例如加载产品信息列表,一般会加载产品图片,这时候为了用户体验,可以先加载产品的其他信息,等其它信息加载完毕后,在发起ajax请求设置async=true,异步加载产品图片。 阅读全文
posted @ 2017-08-22 15:30 AlanLeung 阅读(277) 评论(0) 推荐(0)
摘要:1.JQuery控制radio选中和不选中 通过name $("input:radio[name="analyfsftype"]").eq(0).attr("checked",'checked');$("input:radio[name="analyshowtype"]").attr("checke 阅读全文
posted @ 2017-08-22 15:15 AlanLeung 阅读(408) 评论(0) 推荐(0)
摘要:因为笔者要重装系统,所以用到了光盘,光驱好久没用了,放进去竟然读不出来。 解决办法:把光驱上的尘清理干净,就能用了。 阅读全文
posted @ 2017-06-02 16:09 AlanLeung 阅读(258) 评论(0) 推荐(0)