php的注释到没所谓,html的注释是占流量的,看上去虽然很微小~

解决方案 »

  1.   

    代码注释量在20%-30%之间为宜,不要用带感情色彩的文字。//核心功能,没有投票的可以投
    //投票成功:1.本投票表对应行记录增加一票 2.投票记录表增加该用户的投票记录,投票次数不能大于1。
     
    $voteid=$_GET["voteid"];
    //获得ID,检测其是否投过票 $nowip=$_SERVER["REMOTE_ADDR"];
    $today=date("Ymd");
     
     
    //是否存在记录
    $where="ip='$nowip' and votedate='$today'";
    $record=new Record();
    $res=$record->fetchAll($where)->toArray();
    if(count($res) > 10){
    $this->view->res="您今天已经投过票了";
    $this->render("res");
    }else{
     
    //可以投票
    $recordarr=array(
    "ip"=>$nowip,
    "votedate"=>$today,
    "voteid"=>$voteid
    );
     
     
    //增加一条记录,如果添加成功返回添加成功的id值
    $insertres=$record->insert($recordarr);
    if($insertres){
    //增加该用户投的对应的一票,操作vote表
    $vote=new Vote();
      

  2.   

    哥们,注释简明扼要就好,打中文也挺累的吧?你里面很多一长段话都可以缩略成几个关键词。
    /**
     * 投票核心处理部分
     * 说明:每IP用户每日限制投一票。
     * 流程:投票->判断该ip是否在黑名单->【是】中断并提示信息->判断该IP今日是否投票->【是】提示信息;【否】记录ip投票信息,记录投票内容
     */$voteid=$_GET["voteid"];//ip
    $nowip=$_SERVER["REMOTE_ADDR"];
    $today=date("Ymd");//检查Ip今日是否投票
    $where="ip='$nowip' and votedate='$today'";
    $record=new Record();
    $res=$record->fetchAll($where)->toArray();
    if(count($res) > 10){
    $this->view->res="您今天已经投过票了";
    $this->render("res");
    }else{
     
    //记录已投票ip
    $recordarr=array(
    "ip"=>$nowip,
    "votedate"=>$today,
    "voteid"=>$voteid
    );
    $insertres=$record->insert($recordarr);//成功记录ip则记录投票内容
    if($insertres){
    //操作vote表
    $vote=new Vote();