This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" set the runtime path to include Vundle and initialize | |
set rtp+=~/.vim/bundle/Vundle.vim | |
call vundle#begin() | |
" alternatively, pass a path where Vundle should install plugins | |
"call vundle#begin('~/some/path/here') | |
" let Vundle manage Vundle, required | |
Plugin 'VundleVim/Vundle.vim' | |
Plugin 'vim-airline/vim-airline' | |
Plugin 'vim-airline/vim-airline-themes' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if(typeof str == 'string'){ | |
try{ | |
var obj = JSON.parse(str); | |
return !!obj && typeof obj === 'object'; | |
}catch(e){ | |
return false; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* textarea文本内容空白、换行替换html实体标签 | |
* @param $sContent | |
* @return string|string[]|null | |
*/ | |
function textToHtml($sContent) | |
{ | |
$pattern = array( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//method 1 | |
function msectime() { | |
list($msec, $sec) = explode(' ', microtime()); | |
return (float)sprintf('%.0f', (floatval($msec) + floatval($sec)) * 1000); | |
} | |
//method 2 | |
function msetime2() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getCurrentTime() | |
{ | |
// 获取当前日期 | |
var date = new Date(); | |
// 获取当前月份 | |
var nowMonth = date.getMonth() + 1; | |
// 获取当前是几号 | |
var strDate = date.getDate(); | |
// 添加分隔符“-” | |
var seperator = "-"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function QueryStringToJSON($str) { | |
var pairs = $str.split('&'); | |
var result = {}; | |
pairs.forEach(function(pair) { | |
pair = pair.split('='); | |
result[pair[0]] = decodeURIComponent(pair[1] || ''); | |
}); | |
return JSON.parse(JSON.stringify(result)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
define('^_^', 'smile'); | |
define("TEST",'test'); | |
//直接使用常量名获取 | |
echo TEST; | |
echo PHP_EOL; | |
//echo ^_^;//报错,使用constant获取 | |
$var = constant('^_^'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
session_start(); | |
Header("Content-type: image/gif"); | |
class SecurityCode | |
{ | |
private $codes = ''; | |
function __construct() | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//方法一 | |
$password_length = 8; | |
function make_seed() { | |
list($usec, $sec) = explode(' ', microtime()); | |
return (float) $sec + ((float) $usec * 100000); | |
} | |
srand(make_seed()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//方法一、使用linux命令 | |
file = 'access.log'; | |
$file = escapeshellarg($file); // 对命令行参数进行安全转义 | |
$line = `tail -n 1 $file`; | |
echo $line; | |
//方法二、使用php的fseek | |
//第一种:首先通过fseek找到文件的最后一位EOF,然后找最后一行的起始位置,取这一行的数据,再找次一行的起始位置,再取这一行的位置,依次类推,直到找到了$num行。 | |
function tail($fp,$n,$base=5) |