去掉input阴影&隐藏滚动条&抛异常&预加载&curl传json

1.隐藏滚动条:-webkit-scrollbar{ display:none; }

2.array_walk():数组里的每个元素执行一个自定义函数;

array_map():数组里的每个元素执行一个自定义函数,并返回一个新的函数;

3.去掉input内的阴影:

appearance:none;

-webkit-appearance:none;

3.curl发送json格式的数据:

$data_string =  json_encode($arr);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
    'Content-Type: application/json',
    'Content-Length: ' . strlen($data_string)
));

4.tp框架里的抛异常处理:

try {   
    throw new \Think\Exception("error");  
} catch (\Think\Exception $e) {   
    echo $e->getMessage();   
exit();   
}   

5.PHP版本高于5.5时,curl文件上传必须使用CurlFile对象

$a = new \CURLFile($real_path);

6.从网上down的代码一定要注意全角半角的问题,sublime没有提示,把前边的缩进全部删除自己打上空格;phpstorm有提示

7.预加载图片:

  <script type="text/javascript">
    
      var images = new Array()
      function preload() {
        for (i = 0; i < preload.arguments.length; i++) {
          images[i] = new Image()
          images[i].src = preload.arguments[i]
        }
      }
      preload(
        "http://domain.tld/gallery/image-001.jpg",
        "http://domain.tld/gallery/image-002.jpg",
        "http://domain.tld/gallery/image-003.jpg"
      )
    
  </script>
原文地址:https://www.cnblogs.com/Basu/p/7902522.html