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
$a = 'flower';echo "She received some $as";// 無效;字母s會被當成有效變數名組成元素,但是這裡的變數是$aecho "She received some ${a}s"; // 有效echo "She received some {$a}s"; // 有效;推薦的使用方法
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
在與其他系統進行WEBSERVICE對接的時候發現,PHP無法識別.NET下的時間參數。分析:PHP中的調用WEBSERVICE代碼是手工編寫xml格式的資料包來實現的在與其他系統進行WEBSERVICE對接的時候發現,PHP無法識別.NET下的時間參數。分析:PHP中的調用WEBSERVICE代碼是手工編寫xml格式的資料包來實現的,並不像我們.NET 和
Time of Update: 2016-07-25
$arr1 = array(1,9,5); $arr2 = array(6,2,4); array_multisort($arr1,$arr2); print_r($arr1); // 得到的順序是1,5,9 print_r($arr2); // 得到的順序是6,4,2複製代碼我估計兩個數組的值自始至終都是對應著的:1對應6,9對應2,5對應4。 再加多一個數組看看會怎樣: $arr1 = array(1,9,5); $arr2 = array(6,2,4); $arr3 = array(3,
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
#------------------------------------------# # XML Library, by Keith Devens, version 1.2b # http://keithdevens.com/software/phpxml # # This code is Open Source, released under terms similar to the Artistic License. # Read the license at
Time of Update: 2016-07-25
$arr1 = array('10', 11, 100, 100, 'a'); $arr2 = array(1, 2, 3, '2', 5); array_multisort($arr1, $arr2); ?>複製代碼結果為: $arr1 Array ( [0] => 10 [1] => a [2] => 11 [3] => 100 [4] => 100 ) # '10'在與11, 100, 100比較時轉換為整數10,小於其他三個數 #
Time of Update: 2016-07-25
/**php自動產生月曆link:bbs.it-home.org 2013-3-7*/ function calendar($MM,$YYYY){ if($MM=="") $MM = date("m"); if($YYYY=="") $YYYY = date("Y"); if(checkdate($MM,1,$YYYY)){ $stringDate = strftime("%d %b %Y",mktime (0,0,0,$MM,1,$YYYY));
Time of Update: 2016-07-25
介紹:產生隨機使用者名稱與密碼,在php中可以使用 mt_rand或rand函數,現在 rand 函數在驗證碼中用的較多一些,而產生長字元的隨機碼大多還是使用 mt_rand 函數。介紹:產生隨機使用者名稱與密碼,在php中可以使用 mt_rand或rand函數,現在 rand 函數在驗證碼中用的較多一些,而產生長字元的隨機碼大多還是使用 mt_rand