Time of Update: 2016-07-25
define("PI",3.14);定義一個常量$area = PI*R*R; 計算圓的面積define("URL","http://bbs.it-home.org");echo "my website url is:".URL;?>複製代碼2、系統常量FILE :php程式檔案名稱LINE :PHP程式檔案行數PHP_VERSION:當前解析器的版本號碼PHP_OS:執行當前PHP版本的作業系統名稱可以直接拿來使用,例如要查看執行當前PHP版本的作業系統名稱,就可以寫成 echo
Time of Update: 2016-07-25
array(11) { [0]=> string(15) "HTTP/1.1 200 OK" [1]=> string(35) "Content-Type: text/html;charset=gbk" [2]=> string(17) "Connection: close" [3]=> string(13) "Server: nginx" [4]=> string(35) "Date: Fri,
Time of Update: 2016-07-25
/** * 通用驗證碼類 img.php * 版本:V0.1 * bbs.it-home.org 2013/3/1 */ class ValidateCode { private $charset="abcdefghizklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890"; //隨機因子 private $code; //驗證碼文字 private $codelen=4;
Time of Update: 2016-07-25
/** php產生強密碼 linK:bbs.it-home.org 2013/3/2*/$password_length = 9;function make_seed() {list($usec, $sec) = explode(’ ‘, microtime());return (float) $sec + ((float) $usec * 100000);}srand(make_seed());$alfa =
Time of Update: 2016-07-25
解決php session跨頁面傳遞 session值丟失的問題,有遇到這個問題的朋友,參考下。session的運行機制:解決php session跨頁面傳遞
Time of Update: 2016-07-25
/** @ 設定及保留屬性的類 @ class cleanHtml @ link:bbs.it-home.org @ date:2013/2/28*/ function reg_escape( $str ) { $conversions = array( "^" => "\^", "[" => "\[", "." => "\.", "$" => "\$", "{" => "\{", "*" => "\*", "(" => "\(", "\\" => "
Time of Update: 2016-07-25
//截取中文字串function mysubstr($str, $start, $len) {$tmpstr = "";$strlen = $start + $len;for($i = 0; $i if(ord(substr($str, $i, 1)) > 0xa0) {$tmpstr .= substr($str, $i, 2);$i++;} else$tmpstr .= substr($str, $i, 1);}return $tmpstr;}?>複製代碼2、截取utf8編碼的多位元組字串/
Time of Update: 2016-07-25
/* 從字典檔案中提取隨機值 */$file1 = "./Words.dic";$file2 = "./common_pass_mini.dic";$file3 = "./Sys_Month_Date.Dic";$rfile = "./5.dic";$n = 2000;//提取字典$basef = file($file1);$extf = file($file2);$extf2 = file($file3);$bf_sum = (count($basef)-1);$ef_sum =
Time of Update: 2016-07-25
auto_prepend_file = "c:/Program Files/include/header.php" auto_append_file = "c:/Program Files/include/footer.php"複製代碼unix中這樣設定: auto_prepend_file = "/home/username/include/header.php" auto_append_file =
Time of Update: 2016-07-25
驗證碼請輸入驗證碼複製代碼2、產生驗證碼 auth.php session_start(); header("Content-type:image/png"); $img_width=100; $img_height=20; srand(microtime()*100000); for($i=0;$i { $new_number.=dechex(rand(0,15)); } $_SESSION[check_auth]=$new_number;
Time of Update: 2016-07-25
/* @中文字元入庫亂碼的解決方案 @bbs.it-home.org*/include_once("conn.php");include_once("include.php");mysql_query("set names 'gbk'")or die("設定字元庫失敗\n");mysql_select_db($db)or die("串連資料庫失敗!\n");$exec = "select * from $table";//echo $exec;$result =
Time of Update: 2016-07-25
/* * 參數說明 * $max_file_size : 上傳檔案大小限制, 單位BYTE * $destination_folder : 上傳檔案路徑 * $watermark : 是否附加浮水印(1為加浮水印,其他為不加浮水印); * http://bbs.it-home.org * 使用說明: * 1. 將PHP.INI檔案裡面的"extension=php_gd2.dll"一行前面的;號去掉,因為我們要用到GD庫; * 2. 將extension_dir
Time of Update: 2016-07-25
圖片上傳-bbs.it-home.org檔案上傳(只允許上傳jpg類型圖片)複製代碼2、處理頁面 upload_img.php //上傳圖片儲存地址 $uploadfile = "upfiles/".$_FILES['upfile']['name']; //縮圖儲存地址 $smallfile = "upfiles/small_".$_FILES['upfile']['name']; if($_FILES['upfile']['type'] != "image/jpeg")
Time of Update: 2016-07-25
/** 人民幣金額數字轉中文大寫 link:bbs.it-home.org date:2013-2-28*/function cny($ns) {static
Time of Update: 2016-07-25
/* @名稱:PHP加密/解密 @link:bbs.it-home.org @date:2013/2/28 */ function phpencode($code) { $code = str_replace(array('',' $encode = base64_encode(gzdeflate($code)); // 開始編碼 $encode = '"; return $encode;
Time of Update: 2016-07-25
$(".login").live('click',function(){ var username=$(".input_user").val(); var password=$(".input_ps").val(); var code=$('.input_checkcode').val(); if(username==""){ alert("使用者名稱不可為空");
Time of Update: 2016-07-25
for($i = 0; $i $_md_color = imagecolorallocate($_img,mt_rand(0, 255),mt_rand(0, 255), mt_rand(0, 255)); imageline($_img, mt_rand(0, 75), mt_rand(0, 75), mt_rand(0, 75), mt_rand(0, 75),$_md_color); }//隨機雪花for($i = 0; $i $_md_color =
Time of Update: 2016-07-25
/** @todo 中文截取,支援gb2312,gbk,utf-8,big5* @http://bbs.it-home.org* @param string $str 要截取的字串* @param int $start 截取起始位置* @param int $length 截取長度* @param string $charset utf-8|gb2312|gbk|big5 編碼* @param $suffix 是否加尾綴*/function csubstr($str, $start=0,
Time of Update: 2016-07-25
介紹:產生隨機使用者名稱與密碼,在php中可以使用 mt_rand或rand函數,現在 rand 函數在驗證碼中用的較多一些,而產生長字元的隨機碼大多還是使用 mt_rand 函數。介紹:產生隨機使用者名稱與密碼,在php中可以使用 mt_rand或rand函數,現在 rand 函數在驗證碼中用的較多一些,而產生長字元的隨機碼大多還是使用 mt_rand
Time of Update: 2016-07-25
//隨機產生六位元密碼Beginfunction randStr($len=6,$format='ALL') { switch($format) { case 'ALL': $chars='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-@#~'; break; case 'CHAR': $chars='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-@#~