日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > php >内容正文

php

Thinkphp带表情的评论回复实例

發布時間:2023/12/20 php 31 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Thinkphp带表情的评论回复实例 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
Thinkphp帶表情的評論回復實例

基于Thinkphp開發的一個簡單的帶表情的評論回復實例,可以無限回復,適合新手學習或作為畢業設計作品等。

?

評論提交驗證

1 $(".submit-btn").click(function() { 2 var $this = $(this); 3 var name = $this.parent().siblings().children('.name1').val(); 4 var content = $this.parent().siblings().children('.comment').val(); 5 if (name == "" || content == "") { 6 alert("昵稱或者評論不能為空哦"); 7 return false; 8 } 9 });

?

添加評論

1 $rules = array(//定義動態驗證規則 2 array('comment', 'require', '評論不能為空'), 3 array('username', 'require', '昵稱不能為空'), 4 // array('username', '3,15', '用戶名長度必須在3-15位之間!', 0, 'length', 3), 5 ); 6 $data = array( 7 'content' => I("post.comment"), 8 'ip' => get_client_ip(), 9 'add_time' => time(), 10 'pid' => I('post.pid'), 11 'author' => I('post.username'), 12 ); 13 14 $comment = M("comment"); // 實例化User對象 15 if (!$comment->validate($rules)->create()) {//驗證昵稱和評論 16 exit($comment->getError()); 17 } else { 18 $add = $comment->add($data); 19 if ($add) { 20 $this->success('評論成功'); 21 } else { 22 $this->error('評論失敗'); 23 } 24 }

?

評論遞歸函數

1 function CommentList($pid = 0, &$commentList = array(), $spac = 0) { 2 static $i = 0; 3 $spac = $spac + 1; //初始為1級評論 4 $List = M('comment')-> 5 field('id,add_time,author,content,pid')-> 6 where(array('pid' => $pid))->order("id DESC")->select(); 7 foreach ($List as $k => $v) { 8 $commentList[$i]['level'] = $spac; //評論層級 9 $commentList[$i]['author'] = $v['author']; 10 $commentList[$i]['id'] = $v['id']; 11 $commentList[$i]['pid'] = $v['pid']; //此條評論的父id 12 $commentList[$i]['content'] = $v['content']; 13 $commentList[$i]['time'] = $v['add_time']; 14 // $commentList[$i]['pauthor']=$pautor; 15 $i++; 16 $this->CommentList($v['id'], $commentList, $spac); 17 } 18 return $commentList; 19 }

本文轉自:https://www.sucaihuo.com/php/557.html 轉載請注明出處!

posted on 2019-09-08 11:32?mrlime 閱讀(...) 評論(...) 編輯 收藏

轉載于:https://www.cnblogs.com/mrlime/p/11484878.html

總結

以上是生活随笔為你收集整理的Thinkphp带表情的评论回复实例的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。