关键词:

PHP时间相减获得剩余天数小时数分钟数 <li><a href="/">home page</a></li>//自定义函数:maktimes($second) 输入秒数换算成多少天/多少小时/多少分/多少秒的字符串 function maktimes($second){ $day = floor($second/(3600*24)); $second = $second%(3600*24);//除去整天之后剩余的时间 $hour = floor($second/3600); $second = $second600;//除去整小时之后剩余的时间 $minute = floor($second/60); $second = $second`;//除去整分钟之后剩余的时间 //返回字符串 return $day.'天'.$hour.'小时'.$minute.'分'.$second.'秒'; } //获取从现在到2011年11月11日11点11分11秒还有多久 $time1 = strtotime('2012-3-11 11:11:11'); $time2 = strtotime(now); //相减*相差的 秒 数 $time3 = $time2 - $time1; //输出 echo '从2012年11月3日11点11分11秒到现在还有:'.maktimes($time3); 热门  置顶  发表时间:2020-05-01 23:24:05  点赞:169  评论:4  浏览:1099
获取数据库字段数据的和 // 总贴量 public static function catCode() { return Article::where(['status' => 1])->sum('status'); } 推荐  置顶  发表时间:2020-05-01 23:24:05  点赞:842  评论:0  浏览:1130
thinkPHP6项目中实现QQ第三方登录功能 // 处理qq登录 public function login() { //应用APP ID $app_id = "101549464"; //应用APP Key $app_secret = "06a102ab136ec68afa05624792e5061a"; //应用填写的网站回调域 $my_url = "http://www.ztuc.cn/qqlogin"; //Step1:获取Authorization Code $code=isset($_REQUEST["code"])?$_REQUEST["code"]:0;//存放Authorization Code if(empty($code)) { //state参数用于防止CSRF攻击,成功授权后回调时原样带回 $state = md5(uniqid(rand(), TRUE)); Session::set('state',$state); //拼接URL $dialog_url = "https://graph.qq.com/oauth2.0/authorize?response_type=code&client_id=".$app_id."&redirect_uri=".urlencode($my_url)."&state=".Session::get('state'); return redirect($dialog_url)->send(); } //Step2:通过Authorization Code获取Access Token if($_REQUEST['state'] == Session::get('state') || 1) { //拼接URL $token_url = "https://graph.qq.com/oauth2.0/token?grant_type=authorization_code&"."client_id=".$app_id."&redirect_uri=".urlencode($my_url)."&client_secret=".$app_secret."&code=".$code; $response = file_get_contents($token_url); //如果用户临时改变主意取消登录,返回true!==false,否则执行step3 if (strpos($response, "callback") !== false) { $lpos = strpos($response, "("); $rpos = strrpos($response, ")"); $response = substr($response, $lpos + 1, $rpos - $lpos -1); $msg = json_decode($response); if (isset($msg->error)) { return $msg->error.$msg->error_description; } } //Step3:使用Access Token来获取用户的OpenID $params = array(); parse_str($response, $params);//把传回来的数据参数变量化 $graph_url = "https://graph.qq.com/oauth2.0/me?access_token=".$params['access_token']; $str = file_get_contents($graph_url); if (strpos($str, "callback") !== false) { $lpos = strpos($str, "("); $rpos = strrpos($str, ")"); $str = substr($str, $lpos + 1, $rpos - $lpos -1); } $user = json_decode($str);//存放返回的数据 client_id ,openid if (isset($user->error)) { return $user->error.$user->error_description; } //Step4:使用openid和access_token获取用户信息 $user_data_url = "https://graph.qq.com/user/get_user_info?access_token={$params['access_token']}&oauth_consumer_key={$app_id}&openid={$user->openid}&format=json"; $user_data = json_decode(file_get_contents($user_data_url));//获取到的用户信息 //以下为授权成功后的自定义操作 if($user_data){ //自定义内容 } }else{ return $this->error('未知错误!'); } }else{ return $this->error('The state does not match. You may be a victim of CSRF'); } } 推荐  置顶  发表时间:2020-05-01 23:24:05  点赞:959  评论:0  浏览:1737
JavaScript trim() 方法 实例 去除字符串的头尾空格: var str = " Runoob "; alert(str.trim()); 输出结果: Runoob 最新    发表时间:2022-03-07 12:09:48  点赞:58  评论:0  浏览:352
thinkphp6 添加数据时 显示not support data: #开启路由重写*#问题解决 <IfModule mod_rewrite.c> Options +FollowSymlinks -Multiviews RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*)$ index.php [L,E=PATH_INFO:$1] </IfModule> 热门    发表时间:2020-05-01 23:24:05  点赞:66  评论:0  浏览:554
所有input输入 button才能点击 监听input <script> $("input").on("input",function(){ var getUsername = $("#username").val(); var getMobile = $("#mobile").val(); var getPassword = $("#password").val(); var getEmail = $("#email").val(); var getCaptcha = $("#captcha").val(); $(this).css("color","#232323"); if(getUsername != '' && getMobile != '' && getPassword != '' && getEmail != '' && getCaptcha != ''){ $('#btn').attr('disabled', false).css('background','#009688').css('border','none').css('color','#fff') } else{ $('#btn').attr('disabled', true) } }); </script> 热门    发表时间:2020-05-01 23:24:05  点赞:81  评论:4  浏览:1105
PHP HTML网站在线动态时间显示 <script> function getCurDate() { var d = new Date(); var week; switch (d.getDay()){ case 1: week="星期一"; break; case 2: week="星期二"; break; case 3: week="星期三"; break; case 4: week="星期四"; break; case 5: week="星期五"; break; case 6: week="星期六"; break; default: week="星期天"; } var years = d.getFullYear(); var month = add_zero(d.getMonth()+1); var days = add_zero(d.getDate()); var hours = add_zero(d.getHours()); var minutes = add_zero(d.getMinutes()); var seconds=add_zero(d.getSeconds()); var ndate = years+"年"+month+"月"+days+"日 "+hours+":"+minutes+":"+seconds+" "+week; myTime.innerHTML = ndate; } function add_zero(temp) { if(temp<10) return "0"+temp; else return temp; } setInterval("getCurDate()", 100); </script> <span id="myTime"></span> 最新    发表时间:2020-05-01 23:24:05  点赞:122  评论:0  浏览:898
PHP 数组转换为 JSON 以下实例演示了如何将 PHP 数组转换为 JSON 格式数据: <?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} 以下实例演示了如何解码 JSON 数据: 实例 <?php $json = '{"a":1,"b":2,"c":3,"d":4,"e":5}'; var_dump(json_decode($json)); var_dump(json_decode($json, true)); ?> 以上代码执行结果为: object(stdClass)#1 (5) { ["a"] => int(1) ["b"] => int(2) ["c"] => int(3) ["d"] => int(4) ["e"] => int(5) } array(5) { ["a"] => int(1) ["b"] => int(2) ["c"] => int(3) ["d"] => int(4) ["e"] => int(5) } 最新    发表时间:2020-05-01 23:24:05  点赞:103  评论:0  浏览:981
重置MySQL数据库ID顺序 ALTER TABLE `table_name` DROP `id`; 不删除原有数据!重置后新建自增ID,并设置为主键。 最新    发表时间:2020-05-01 23:24:05  点赞:491  评论:0  浏览:770
ip自带函数转数字 $a=ip2long($ip);ip转数字 echo $a; 最新    发表时间:2020-05-01 23:24:05  点赞:489  评论:0  浏览:769
copyright © 2016-2022 all rights reserved.  网站备案/许可证号 蜀ICP备18033389号-2