奥林达的彩色房子, 巴西 (© Robert Pekar/Alamy)

Welcom to 评论 - lizhenqiu blog!

    #1046

    作者:广西南宁市
    大家三观不同,不必相互理解。
    #,广西南宁市,2017-08-26,09:30:33, 佩服楼主以及楼上几位严谨的态度,和你们相处一定很累
    文章:@意见反馈/技术支持/伊网/安企网  发表时间:2017-08-26, 09:29:26  
    展开↯

    #1047

    作者:广西南宁市
    如何调整 Windows10 基准音量响度
    文章:@意见反馈/技术支持/伊网/安企网  发表时间:2017-08-26, 09:23:57  
    展开↯

    #1048

    作者:广西南宁市
    火车票查询座位
    文章:js 删除前confirm确认提示代码  发表时间:2017-08-26, 08:59:22  
    展开↯

    #1049

    作者:广西南宁市
    文章:从Hello World说起  发表时间:2017-08-25, 15:15:09  
    展开↯

    #1050

    作者:广西南宁市
    php mysql 数据库乱码
    mysql_query("set character set 'utf8'");//读库 mysql_query("set names 'utf8'");//写库
    Run code
    Cut to clipboard

      echo mysql_error()函数显示错误
      MySQL更新某个字段的值为原来的值加1
      update student set score=score+1 where
      Run code
      Cut to clipboard

        PHP获取MySql新增记录ID值
        <?php //执行插入数据库的语句 //…… $getID=mysql_insert_id();//$getID即为最后一条记录的ID //此函数的使用条件: //1.假设字段名称为recordID //2.字段属性须设为:auto_increment //3.添加数据后使用 //$newID = mysql_insert_id(); //得到ID值 ?>
        Run code
        Cut to clipboard
          #,广西南宁市,2017-08-25,11:53:58,
          <?php session_start(); $con = mysql_connect("127.0.0.1","******","*******"); @mysql_select_db("ainamysql", $con); @mysql_query("SET NAMES UTF8"); //检测订单 2016.8.27 if($_SESSION['chongzhi_mod']==2) {
          Run code
          Cut to clipboard
            #,广西南宁市,2017-08-25,15:08:06,
            SET NAMES 'utf8'; 它相当于下面的三句指令: SET character_set_client = utf8; SET character_set_results = utf8; SET character_set_connection = utf8;
            Run code
            Cut to clipboard
              文章:常用html、demo代码  发表时间:2016-09-09, 01:01:16  
              展开↯

              #1051

              作者:广西南宁市
              JS使用http协议实现ping功能
              目前项目需要用到,实现原理很简单,提交一个ajax请求,并分别记录发送时间和收到回复时间即可。
              $.ping = function(option) { var ping, requestTime, responseTime ; var getUrl = function(url){ //保证url带http:// var strReg="^((https|http)?://){1}" var re=new RegExp(strReg); return re.test(url)?url:"http://"+url; } $.ajax({ url: getUrl(option.url)+'/'+ (new Date()).getTime() + '.html', //设置一个空的ajax请求 type: 'GET', dataType: 'html', timeout: 10000, beforeSend : function() { if(option.beforePing) option.beforePing(); requestTime = new Date().getTime(); }, complete : function() { responseTime = new Date().getTime(); ping = Math.abs(requestTime - responseTime); if(option.afterPing) option.afterPing(ping); } }); if(option.interval && option.interval > 0) { var interval = option.interval * 1000; setTimeout(function(){$.ping(option)}, interval); // option.interval = 0; // 阻止多重循环 // setInterval(function(){$.ping(option)}, interval); } };
              Run code
              Cut to clipboard
                文章:怎么用javascript实现ping一个主机代码  发表时间:2017-08-25, 15:05:17  
                展开↯

                #1052

                作者:广西南宁市
                php怎么判断用户的网络速度快慢
                $fp=fopen("cs.txt","w"); for($i=0;$i<170400;$i++){ fwrite($fp,"test"); } fclose($fp); //计算网速 function getmicrotime() { list($usec,$sec) = explode("",microtime()); return ((float)($usec) + (float)($sec)); } $data = file_get_contents("cs.txt"); $start = getmicrotime(); $filesize = filesize("cs.txt") / 1024; echo "<!--".$data."-->"; $stop = getmicrotime(); $duration = ($stop - $start); $speed = round($filesize/$duration,2); echo "你的网速:$speed kB/秒";
                Run code
                Cut to clipboard
                  文章:怎么用javascript实现ping一个主机代码  发表时间:2017-08-25, 15:04:20  
                  展开↯

                  #1053

                  作者:广西南宁市
                  这样 ping('www.lizhenqiu.com/img/bdlogo.gif');
                  ,只能用 图片url,直接域名不行的
                  #,广西南宁市,2017-08-25,15:03:26,
                  <!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <title>HTTP Ping</title> <style> html { height: 100%; overflow: hidden; } body { background: #000; color: #C0C0C0; font: bold 14px 'Lucida Console'; height: 100%; margin: 0 0 0 5px; } #divContent { height: 90%; overflow: auto; } #txtTimeout { width: 40px; } button { margin-left: 10px; } </style> </head> <body> <div id="divInput"> <span>Host:</span> <input id="txtURL" type="text" /> <span>Timeout:</span> <input id="txtTimeout" type="text" value="2000" /> <input id="btnSwitch" type="button" value="Start" onclick="handleClick()" /> <hr/> </div> <div id="divContent"></div> <script> var iSeq = 0; var iSent, iReply; var iSum, iMax, iMin; var sURL, iTimeout; var bRunning = false; var tick, tid; function reply() { if(!bRunning || this.seq != iSeq) return; /* * 取消超时计时 */ clearTimeout(tid); ++iReply; var delay = new Date - tick; iSum += delay; if(delay > iMax) iMax = delay; if(delay < iMin) iMin = delay; println("Reply from " + sURL + " time" + ((delay<1)? ("<1") : ("="+delay)) + "ms"); tid = setTimeout(ping, Math.max(1000-delay, 1000)); } function ping() { tick = +new Date; ++iSent; tid = setTimeout(timeout, iTimeout); var oImg = new Image; oImg.onload = reply; oImg.onerror = reply; oImg.seq = ++iSeq; // 发送请求 oImg.src = sURL + "/" + tick + ".html"; } function timeout() { if(!bRunning) return; println("Request timed out."); ping(); } </script> <script> function $(v){return document.getElementById(v)} var oBtn = $("btnSwitch"); var oContent = $("divContent"); var txtURL = $("txtURL"); txtURL.value = location.host; function handleClick() { if(bRunning) { /* * 停止 */ oBtn.value = "Start"; bRunning = false; clearTimeout(tid); /* * 统计结果 */ var lost = iSent - iReply; println(" "); println("Ping statistics for " + sURL + ":"); println("  Packets: Sent = " + iSent + ", Received = " + iReply + ", Lost = " + lost + " (" + Math.round(lost / iSent * 100) + "% loss),"); if(iReply == 0) return; println("Approximate round trip times in milli-seconds:"); println("  Minimum = " + iMin + "ms, Maximum = " + iMax + "ms, Average = " + Math.round(iSum / iReply) + "ms"); } else { /* * 开始 */ sURL = txtURL.value; if(sURL.length == 0) return; if(sURL.substring(0,7).toLowerCase() != "http://") sURL = "http://" + sURL; iTimeout = parseInt($("txtTimeout").value, 10); if(isNaN(iTimeout)) iTimeout = 2000; if(iTimeout < 1000) iTimeout = 1000; oBtn.value = "Stop "; bRunning = true; iSent = 0; iReply = 0; iSum = 0; iMax = -1; iMin = 1e9; cls(); println("Pinging " + sURL + ":"); println(" "); ping(); } } function println(str) { var div = document.createElement("div"); if(div.innerText != null) div.innerText = str; else div.textContent = str; oContent.appendChild(div); oContent.scrollTop = oContent.scrollHeight; } function cls() { oContent.innerHTML = ""; } </script> </body> </html>
                  Run code
                  Cut to clipboard
                    文章:怎么用javascript实现ping一个主机代码  发表时间:2017-08-25, 15:02:39  
                    展开↯

                    #1054

                    作者:广西南宁市
                    文章:从Hello World说起  发表时间:2017-08-25, 14:23:06  
                    展开↯

                    #1055

                    作者:广西南宁市

                    文章:微信支付错误两个问题的解决:curl出错,错误码:60  发表时间:2017-08-25, 11:41:02  
                    展开↯

                    #1056

                    作者:广西南宁市
                    //打印输出数组信息 function printf_info($data) { foreach($data as $key=>$value){ echo "<font color='#00ff55;'>$key</font> : $value <br/>"; } }
                    Run code
                    Cut to clipboard
                      文章:自定义数组格式化输出函数(dump),调试程序时很有用  发表时间:2017-08-25, 11:36:58  
                      展开↯

                      #1057

                      作者:广西南宁市
                      怎么在thinkphp的视图模板中把固定的时间戳转为时间格式
                      用实例化Model类的方法,从数据库里获取出来的时间戳,如何在模板中用正常的时间格式来显示?
                      1、使用date函数进行转换即可。
                      2、先在控制器中将时间戳分配给模板:
                      $this->assign('time',$time);
                      Run code
                      Cut to clipboard

                        3、在模板里面:
                        {$time|date="Y-m-d H:i",###}
                        Run code
                        Cut to clipboard

                          查询按in排序
                          thinkphp 如何实现在用in条件查询时,返回结果按in排序。
                          order()里条件应该怎么写。
                          M('table')->where("id in ('3','4','2','5','1')")->order("field(id,'3','4','2','5','1')")->select();
                          Run code
                          Cut to clipboard

                            php怎么根据数组中其中的一个值排序
                            php数组按键值排序
                            $arr = array('a'=>1,'c'=>3,'b'=>2); asort($arr); 这样的排序我已经知道了 但是 如果一个二维数组 $arr[] = array('name'=>'a','flag'=>1); $arr[] = array('name'=>'b','flag'=>2); $arr[] = array('name'=>'a','flag'=>1); 我只想根据 键flag为的值 进行排序 期望的效果为: $arr[] = array('name'=>'a','flag'=>1); $arr[] = array('name'=>'a','flag'=>1); $arr[] = array('name'=>'b','flag'=>2);
                            Run code
                            Cut to clipboard

                              $arr[] = array('name'=>'a','flag'=>1); $arr[] = array('name'=>'b','flag'=>2); $arr[] = array('name'=>'a','flag'=>1); $flag=array(); foreach($arr as $arr2){ $flag[]=$arr2["flag"]; } array_multisort($flag, SORT_ASC, $arr); print_r($arr);
                              Run code
                              Cut to clipboard

                                说明
                                array_multisort() 函数对多个数组或多维数组进行排序。
                                参数中的数组被当成一个表的列并以行来进行排序 - 这类似 SQL 的 ORDER BY 子句的功能。第一个数组是要排序的主要数组。数组中的行(值)比较为相同的话,就会按照下一个输入数组中相应值的大小进行排序,依此类推。
                                第一个参数是数组,随后的每一个参数可能是数组,也可能是下面的排序顺序标志(排序标志用于更改默认的排列顺序)之一:
                                SORT_ASC - 默认,按升序排列。(A-Z) SORT_DESC - 按降序排列。(Z-A)
                                Run code
                                Cut to clipboard

                                  随后可以指定排序的类型:
                                  SORT_REGULAR - 默认。将每一项按常规顺序排列。 SORT_NUMERIC - 将每一项按数字顺序排列。 SORT_STRING - 将每一项按字母顺序排列。
                                  Run code
                                  Cut to clipboard
                                    #,广西南宁市,2017-08-25,10:26:21,
                                    //购物车商品联动 function getProCart($oid,$rtotal,$myorder){ $wp['id']=array('in','0,'.$oid); $plist=M('custom_reply_news')->where($wp)->select(); $mid=$this->mChacklogin(); $wc['pid']=array('in',$oid); $wc['mid']=$mid; $wc['_string']='pay=0 or pay=1'; if($myorder) $wc['_string']='pay=2 or pay=1'; //$wc['pay']=0;//0购物车1未支付2已支付3删除 //order('field(dtime,'.$oid.')') //order('dtime desc')-> $clist=M('cart')->where($wc)->select(); //dump($clist);exit; if($myorder){ //我的订单 修复同个商品不同支付状态多个购物订单 $flag=array(); foreach($plist as $pk=>$pv){ foreach($clist as $ck=>$cv){ if($pv['id']==$cv['pid']){ $flag[]=$cv['dtime']; $pv['count']=$cv['count']; $pv['newprice']=$cv['count']*$pv['price']; $total=$total+$pv['newprice']; $pv['total']=$total; $pv['pay']=$cv['pay']; $pv['pid']=$cv['id']; $pv['dtime']=$cv['dtime']; $newolist[]=$pv; } } //dump($newolist);exit; } array_multisort($flag, SORT_DESC , $newolist); }else{ foreach($clist as $ck=>$cv){ foreach($plist as $pk=>&$pv){ if($pv['id']==$cv['pid']){ $pv['count']=$cv['count']; $pv['newprice']=$cv['count']*$pv['price']; $total=$total+$pv['newprice']; $pv['total']=$total; $pv['pay']=$cv['pay']; $pv['pid']=$cv['id']; $pv['dtime']=$cv['dtime']; } } } } if($myorder) return $newolist; if($rtotal){ $csWeiSite=(getAddonConfig( 'WeiSite' )); return $total+$csWeiSite['sssssxl_cz']; } return $plist; }
                                    Run code
                                    Cut to clipboard
                                      #,广西南宁市,2017-08-25,10:31:16,
                                      PHP str_ireplace() 函数 php替换字符串替换
                                      注意返回值,返回类型,原变量,新变量
                                      <?php echo str_ireplace("WORLD","Shanghai","Hello world!"); ?>
                                      Run code
                                      Cut to clipboard

                                        "Hello world!"不变,产生新替换变量,区别上面数组,排序后原数组改变,返回
                                        展开↯

                                        #1058

                                        作者:广西南宁市
                                        js 重写alert 兼容iphone使得alert 不带src
                                        <script> window.alert = function(name){ var iframe = document.createElement("IFRAME"); iframe.style.display="none"; iframe.setAttribute("src", 'data:text/plain,'); document.documentElement.appendChild(iframe); window.frames[0].window.alert(name); iframe.parentNode.removeChild(iframe); } </script>
                                        Run code
                                        Cut to clipboard
                                          #,广西南宁市,2017-08-24,17:44:44,
                                          重写alert方法,去掉地址显示 //重写alert方法,去掉地址显示 window.alert = function(name){ var iframe = document.createElement("IFRAME"); iframe.style.display="none"; iframe.setAttribute("src", 'data:text/plain,'); document.documentElement.appendChild(iframe); window.frames[0].window.alert(name); iframe.parentNode.removeChild(iframe); } //重写confirm方法,去掉地址显示 window.confirm = function(name){ var iframe = document.createElement("IFRAME"); iframe.style.display="none"; iframe.setAttribute("src", 'data:text/plain,'); document.documentElement.appendChild(iframe); var result = window.frames[0].window.confirm(name); iframe.parentNode.removeChild(iframe); return result; }
                                          Run code
                                          Cut to clipboard
                                            #,广西南宁市,2017-08-24,18:47:39,
                                            ios移动端(H5)alert/confirm提示信息去除网址(URL)
                                            在android中 有问题,过滤android var browser={ versions:function(){ var u = navigator.userAgent, app = navigator.appVersion; return { trident: u.indexOf('Trident') > -1, //IE内核 presto: u.indexOf('Presto') > -1, //opera内核 webKit: u.indexOf('AppleWebKit') > -1, //苹果、谷歌内核 gecko: u.indexOf('Gecko') > -1 && u.indexOf('KHTML') == -1,//火狐内核 mobile: !!u.match(/AppleWebKit.*Mobile.*/), //是否为移动终端 ios: !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/), //ios终端 android: u.indexOf('Android') > -1 || u.indexOf('Linux') > -1, //android终端或者uc浏览器 iPhone: u.indexOf('iPhone') > -1 , //是否为iPhone或者QQHD浏览器 iPad: u.indexOf('iPad') > -1, //是否iPad webApp: u.indexOf('Safari') == -1 //是否web应该程序,没有头部与底部 }; }(), language:(navigator.browserLanguage || navigator.language).toLowerCase() } if(browser.versions.ios){ window.alert = function(name){ var iframe = document.createElement("IFRAME"); iframe.style.display="none"; iframe.setAttribute("src", 'data:text/plain,'); document.documentElement.appendChild(iframe); window.frames[0].window.alert(name); iframe.parentNode.removeChild(iframe); }; window.confirm = function (message) { var iframe = document.createElement("IFRAME"); iframe.style.display = "none"; iframe.setAttribute("src", 'data:text/plain,'); document.documentElement.appendChild(iframe); var alertFrame = window.frames[0]; var result = alertFrame.window.confirm(message); iframe.parentNode.removeChild(iframe); return result; }; }
                                            Run code
                                            Cut to clipboard

                                              <script> window.alert = function(name){ var iframe = document.createElement("IFRAME"); iframe.style.display="none"; iframe.setAttribute("src", 'data:text/plain,'); document.documentElement.appendChild(iframe); window.frames[0].window.alert(name); iframe.parentNode.removeChild(iframe); } window.confirm = function (message) { var iframe = document.createElement("IFRAME"); iframe.style.display = "none"; iframe.setAttribute("src", 'data:text/plain,'); document.documentElement.appendChild(iframe); var alertFrame = window.frames[0]; var result = alertFrame.window.confirm(message); iframe.parentNode.removeChild(iframe); return result; }; </script>
                                              Run code
                                              Cut to clipboard
                                                文章:on click事件在移动端点击无效bug  发表时间:2017-08-24, 16:45:00  
                                                展开↯

                                                #1059

                                                作者:广西南宁市
                                                拜读一下,根据PHP中的函数读取头部信息,然后用substr截取
                                                文章:在图片onload前获取图片的大小  发表时间:2017-08-24, 17:31:46  
                                                展开↯

                                                #1060

                                                作者:广西南宁市
                                                border-top-left-radius: <length> <length> //左上角 border-top-right-radius: <length> <length> //右上角 border-bottom-right-radius:<length> <length> //右下角 border-bottom-left-radius:<length> <length> //左下角
                                                Run code
                                                Cut to clipboard
                                                  文章:CSS小三角形和阴影效果  发表时间:2017-08-24, 17:22:59  
                                                  展开↯

                                                  #1061

                                                  作者:广西南宁市
                                                  <?php $file = '0.txt'; $data = file($file); $str = ''; foreach($data as $val) { $val = trim($val); $str .= $val. "\t" . '1' . "\r\n"; $str .= 'x:1' . "\r\n"; } file_put_contents('717add_dict.txt', $str);
                                                  Run code
                                                  Cut to clipboard
                                                    展开↯

                                                    #1062

                                                    作者:广西南宁市
                                                    <?php $json = '{"a":1,"b":2,"c":3,"d":4,"e":5}'; var_dump(json_decode($json)); //返回 object var_dump(json_decode($json, true)); //返回 array ?>
                                                    Run code
                                                    Cut to clipboard

                                                      <?php $arr = array ('a'=>1,'b'=>2,'c'=>3,'d'=>4,'e'=>5); echo json_encode($arr); //输出:{"a":1,"b":2,"c":3,"d":4,"e":5} ?>
                                                      Run code
                                                      Cut to clipboard
                                                        文章:php curl打开网页  发表时间:2017-08-24, 11:35:47  
                                                        展开↯

                                                        #1063

                                                        作者:广西南宁市
                                                        PHP数字价格格式化,保留两位小数
                                                        我们需要将价格保留两位小数比如12元需要表示为¥12.00,这时就需要使用number_format函数,使用方法为number_format(12,2),如果需要四舍五入,可以使用round函数配合。

                                                        number_format
                                                        格式化数字字串。

                                                        语法: string number_format(float number, int [decimals], string [dec_point], string [thousands_sep]);
                                                        传回值: 字串
                                                        函式种类: 数学运算
                                                        内容说明
                                                        本函式用来将浮点参数 number 格式化。若没加参数 decimals 则传回的字串只要整数部份,加了此参数才依参数指定的小数点位数传回。参 数 dec_point 表示小数点的表示方式方法,内定值是 ”.”,若需要转换成其它的小数点就可以在这个参数改掉。参 数 thousands_sep 为整数部份每三位的分隔符号,内定值是 ”,”。本函式最特别的地方就是参数数目,最少要有一个,也就是欲格式化的字 串;也可以有二个或者四个参数,但不能用三个参数。值得注意的是指定小数点的位数之后的数字直接舍弃,没有四舍五入的情形。

                                                        描述
                                                        number
                                                        必需。要格式化的数字。

                                                        如果未设置其他参数,则数字会被格式化为不带小数点且以逗号 (,) 作为分隔符。

                                                        decimals 可选。规定多少个小数。如果设置了该参数,则使用点号 (.) 作为小数点来格式化数字。
                                                        decimalpoint 可选。规定用作小数点的字符串。
                                                        separator
                                                        可选。规定用作千位分隔符的字符串。

                                                        仅使用该参数的第一个字符。比如 "xyz" 仅输出 "x"。

                                                        注释:如果设置了该参数,那么所有其他参数都是必需的。

                                                        例子:
                                                        <?php   echo number_format("1000000");   echo number_format("1000000",2);   echo number_format("1000000",2,",",".");   echo number_format("1000000",2,"*",".");   echo number_format("1000000",2,".",""); ?>
                                                        Run code
                                                        Cut to clipboard

                                                          输出:

                                                          1,000,000
                                                          1,000,000.00
                                                          1.000.000,00
                                                          1.000.000*00
                                                          1000000.00



                                                          有意思的number_format
                                                          number_format(number,decimals,decimalpoint,separator)

                                                          有四个参数,

                                                          第一个和第二个参数是必须的,第三个和第四个是可选项。但实际测试中第三个和第四个这两个参数必须同时存在,也就是要么都设置,要么都不设置。

                                                          没有设置第三个和第四个参数:

                                                          Number_format(13526, 2); echo 13,526.00;

                                                          如果你将这处理后的数字去累加,则只会得到一个13!。

                                                          设置了第三个和第四个参数

                                                          Number_format(23125, 2, ‘.',''); echo 23125.00;

                                                          这时再对这处理后的数字进行运算的话则会正确执行!

                                                          该函数的第三个参数表示 ‘小数点'位置用什么来表示,可以默认 . ,也可以设置成‘,'等其他符号。Ps:但我相信没人会这么干。
                                                          第四个则表示每隔 千位时用什么来分割数字。如果没什么特殊要求,又要进行运算的话最好设置为空。
                                                          文章:JS浮点数运算多出很多位小数点Bug的解决办法  发表时间:2017-08-24, 11:31:17  
                                                          展开↯

                                                          #1064

                                                          作者:上海市
                                                          原来还有人再用我多年前搞的blog!!!
                                                          #,广西南宁市,2017-08-24,01:27:47, 感谢
                                                          文章:常用数据存贮存储本地数据缓存  发表时间:2017-08-23, 21:24:17  
                                                          展开↯
                                                          你好,残忍屏蔽广告

                                                          确定要清除编辑框内容吗?

                                                          该删除操作将不可恢复。

                                                          删除 取消

                                                          激活Windows

                                                          转到"设置"以激活Windows。