zoukankan      html  css  js  c++  java
  • thinkphp小技巧

    if(IS_POST) _404("页面不存在",U("index"))               //如果不是POST提交,则跳转到index。debug模式中不跳转,显示string。

    if(IS_POST) halt("页面不存在")                                 //更详细的错误信息,页面可定制

    M(表名)->data($data)->add()                                  //向数据库添加数据

    M(表名)->where(array('id'=>array('gt',0)))->delete()    //删除id>0    where是必须条件

    $this->success("成功",U("index"))                             //成功执行,并跳转

    $this->error("失败")                                                   //失败执行,并跳转。默认跳转回提交页面

    {$v.time | date='y-m-s H-i', ###}                               //web页面中显示,并且格式化时间

    F('filename',$filedata,'/dir/')                                        //将数据$filedata存入路径dir下,文件名是filename

    $this->ajaxReturn(array('status'=>0),'json')                      //常用返回

     addslashes($arr)                                                             //string  转义

    ini_get("session.gc_maxlifetime")                                         //取得参数

    在html中<script>中使用thinkphp模板{}定义变量 然后可供js使用

    <css  file="../name.css"/>     <js  file="name.js" />                                                     新型引用标签

    {... $v['id']...}                                                                      //再模版中使用时,需要使用原生数组取值,不能直接$v.id

  • 相关阅读:
    分页得到查询总数的方法 mysql
    input[type="file"] change事件第二次不触发
    小程序post请求,后台接收不到数据的解决方法
    Docker安装Kibana
    Docker安装ElasticSearch
    Docker安装Redis
    Docker安装Tomcat
    Docker安装 Nginx
    mysql服务设置远程连接 解决1251 client does not support ..问题
    Docker 安装MySQL容器
  • 原文地址:https://www.cnblogs.com/olenji/p/4862661.html
Copyright © 2011-2022 走看看