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
/*** FILE_NAME : arr.php FILE_PATH : test/* 在多維陣列中根據鍵名快速查詢其父鍵以及父索引值** @copyright Copyright (c) 2006-2010* @author Levi* @package test.arr* @subpackage* @version 2011-04-29* @link bbs.it-home.org*/header("Content-Type: text/html; charset=utf-8");$arr
Time of Update: 2016-07-25
/***PHPMailer 樣本*/require_once('class.phpmailer.php');require_once('class.pop3.php');$username = getenv('username');$password = getenv('password');$pop = new POP3();$auth = $pop->Authorise('your.mailserver.com', 110, 30, "$username", "$password", 1);
Time of Update: 2016-07-25
//判斷遠程檔案function check_remote_file_exists($url){$curl = curl_init($url);// 不取回資料curl_setopt($curl, CURLOPT_NOBODY, true);// 發送請求$result = curl_exec($curl);$found = false;// 如果請求沒有發送失敗if ($result !== false) {// 再檢查http響應碼是否為200$statusCode =
Time of Update: 2016-07-25
// Start snipit 1$sql = "SELECT * from ";$result = mysql_query($sql);while ($row = mysql_fetch_assoc($result)) {// do stuff with $row}mysql_data_seek($result, 0); //關鍵是這兒while ($row = mysql_fetch_assoc($result)) {// do other stuff with
Time of Update: 2016-07-25
//----saddslashesfunction daddslashes($string, $force = 0, $strip = FALSE) {//字串或數組 是否強制 是否去除//如果魔術引用未開啟 或 $force不為0if(!MAGIC_QUOTES_GPC || $force) {if(is_array($string)) { //如果其為一個數組則迴圈執行此函數foreach($string as $key => $val) {$string[$key] =
Time of Update: 2016-07-25
class runTime {private $starTime;//開始時間private $stopTime;//結束時間private function getMicTime(){$mictime=microtime();//擷取時間戳記和微秒數list($usec,$sec)=explode(" ",$mictime);//把微秒數分割成數組並轉換成變數處理return (float)$usec+(float)$sec;//把轉換後的資料強制用浮點點來處理}public
Time of Update: 2016-07-25
/*** 計算程式已耗用時間* filename: js_runtime.php*/class Timer {private $StartTime = 0;//程式運行開始時間private $StopTime = 0;//程式運行結束時間private $TimeSpent = 0;//程式運行花費時間function start(){//程式運行開始$this->StartTime = microtime();}function stop(){//程式運行結束$this->StopTime
Time of Update: 2016-07-25
class word{function start(){ob_start();print'xmlns:w="urn:schemas-microsoft-com:office:word"xmlns="http://www.w3.org/TR/REC-html40">';}function save($path){print "";$data = ob_get_contents();ob_end_clean();$this->wirtefile ($path,$data);}function
Time of Update: 2016-07-25
$pic = 'abc.3434.342.12123.123.exe';$pics = explode('.' , $pic);/*得到數組總數,然後取最後一個*/echo $num = count($pics);echo ''.$pics[$num-1];/*遍曆數組,取得最後一個元素*/foreach ($pics as $value) //2{$a = $value;}echo $a.'';/*直接輸出數組最後一個元素*/echo end($pics);echo
Time of Update: 2016-07-25
# vim /etc/php.inidisplay_errors = Offlog_errors = Onerror_log = /var/log/php-error.log複製代碼另外也可以設定error_log = syslog,使這些錯誤資訊記錄到作業系統的日誌裡。display_errors = Off //display中文意思是顯示所以display_error=off的意思就是不顯示錯誤了!error_reporting
Time of Update: 2016-07-25
//$count為分類等級sort_list($str,$fatherid,$count){$rs = $this->sql->re_datas("select * from sort where father_id = fatherid");$num = $this->sql->sql_numrows();$i=0;$n = 1;while(isset($rs[$i])){$name = "";for($n = 1 ; $n {$name.="│
Time of Update: 2016-07-25
/*** 批量修改檔案尾碼名 * func: foreachDir*/function foreachDir($path){$handle=opendir($path);if($handle){while (false !== ($file = readdir($handle))) {if($file!="." && $file!='..'){if(is_dir($path.$file)){echo
Time of Update: 2016-07-25
/*—————————————————— *///– 遞迴實現無限分類產生下拉式清單函數//– $tpl->assign('sort_list',createSortOptions ());//– $tpl->assign('sort_list',createSortOptions ($sort_id));/*—————————————————— */function createSortOptions ($selected=0,$parent_id=0,$n=-1){global
Time of Update: 2016-07-25
$stid = isset($_GET['stid'])?$_GET['stid']:0;$endid = $stid + 100;$maxid = 10000;function dosomething(){//要時間比較多的操作……}$sql_string=”select * from `table` where id>’$stid’ and id$datas = getdata_bysql($sql_string);foreach($datas as
Time of Update: 2016-07-25
很多人都會問關於PHP/java程式員薪資與工作經驗年限的內容,無論是在就業論壇的評論還是作為網上流傳的指導性文章,都會涉及這方面的問題。例如,有人知道3年Java/ JEE工作經驗的工資是多少嗎?本人擁有10年Java/
Time of Update: 2016-07-25
function topIp($logfile,$length=3){ $handle = fopen($logfile, 'r'); $countip = array();//統計ip if ($handle) { while ($buffer = fgets($handle)) {//逐行讀取檔案 $arr = preg_split('/\t/',$buffer); if(strstr($arr[2],"small"
Time of Update: 2016-07-25
# 設定 PHP 目錄的別名ScriptAlias /php/ "D:/usr/local/php"# 關聯特定的副檔名,以解析PHP檔案AddType application/x-httpd-php .php# 設定使用 PHP5 執行 CGI 指令碼的程式Action application/x-httpd-php "/php/php-cgi.exe"複製代碼2、以 Apache 模式運行PHP對於PHP5,需要配置以下內容: # 載入 PHP5 模組 LoadModule
Time of Update: 2016-07-25
大多數的 JavaScript 架構如 jquery,Mootools 等,在發出 Ajax 請求時,都會發送額外的 HTTP_X_REQUESTED_WITH 頭部資訊,頭當他們一個ajax請求,因此可以在伺服器端偵測到 Ajax 請求。大多數的 JavaScript 架構如 jquery,Mootools 等,在發出 Ajax 請求時,都會發送額外的 HTTP_X_REQUESTED_WITH 頭部資訊,頭當他們一個ajax請求,因此可以在伺服器端偵測到 Ajax