bsp; $password = ''''; $alt = time() % 2; for ($i = 0; $i < $length; $i++) { if ($alt == 1) { $password .= $consonants[(rand() % strlen($consonants))]; $alt = 0; } else { $password .= $vowels[(rand() % strlen($vowels))]; $alt = 1; } } return $password; }
压缩多个CSS文件
- header(''Content-type: text/css'');
- ob_start("compress");
- function compress($buffer) {
- /* remove comments */
- $buffer = preg_replace(''!/\*[^*]*\*+([^/][^*]*\*+)*/!'', '''', $buffer);
- /* remove tabs, spaces, newlines, etc. */
- $buffer = str_replace(array("\r\n", "\r", "\n", "\t", '' '', '' '', '' ''), '''', $buffer);
- return $buffer;
- }
-
- /* your css files */
- include(''master.css'');
- include(''typography.css'');
- include(''grid.css'');
- include(''print.css'');
- include(''handheld.css'');
-
- ob_end_flush();
获取短网址
- function getTinyUrl($url) {
- return file_get_contents("http://tinyurl.com/api-create.php?url=".$url);
- }
根据生日计算年龄
- function age($date){
- $year_diff = '''';
- $time = strtotime($date);
- if(FALSE === $time){
- return '''';
- }
-
- $date = date(''Y-m-d'', $time);
- list($year,$month,$day) = explode("-",$date);
- $year_diff = date("Y") – $year;
- $month_diff = date("m") – $month;
- $day_diff = date("d") – $day;
- if ($day
|