Time of Update: 2016-07-25
function compress_html($string) { $string = str_replace("\r\n", '', $string); //清除分行符號 $string = str_replace("\n", '', $string); //清除分行符號 $string = str_replace("\t", '', $string); //清除定位字元 $pattern = array ( "/> *([^ ]*
Time of Update: 2016-07-25
/** * +-------------------------------------------------------------------- * Description 遞迴建立目錄 +-------------------------------------------------------------------- * @param string $dir 需要創新的目錄 +----------------------------------------------------
Time of Update: 2016-07-25
function getfirstchar($s0) {$fchar = ord(substr($s0, 0, 1));if (($fchar >= ord("a") and $fchar = ord("A") and $fchar $s = iconv("UTF-8", "gb2312", $s0);$asc = ord($s{0}) * 256 + ord($s小貝)-65536;if ($asc >= -20319 and $asc if ($asc >= -20283 and $asc
Time of Update: 2016-07-25
這個php函數可以把指定的顏色變得更深一些 function ColorDarken($color, $dif=20){ $color = str_replace('#', '', $color); if (strlen($color) != 6){ return '000000'; } $rgb = ''; for ($x=0;$x $c = hexdec(substr($color,(2*$x),2)) - $dif; $c =
Time of Update: 2016-07-25
function getPicture($url,$pictureName){if ($url == "") return false;//擷取圖片的副檔名$info = getimagesize($url);$mime = $info['mime'];$type = substr(strrchr($mime,'/'), 1);//不同的圖片類型選擇不同的圖片產生和儲存函數switch($type){case 'jpeg':$img_create_func =
Time of Update: 2016-07-25
function show_page($count,$page,$page_size){$page_count = ceil($count/$page_size); //計算得出總頁數$init=1;$page_len=7;$max_p=$page_count;$pages=$page_count;//判斷當前頁碼$page=(empty($page)||$page//擷取當前頁url$url =
Time of Update: 2016-07-25
function quicksortX(&$seq){ $stack = array($seq); $sort = array(); while ($stack) { $arr = array_pop($stack); if(count($arr) if (count($arr) == 1) { $sort[] = &$arr[0]; }
Time of Update: 2016-07-25
php計算串連的mysql資料庫的大小,用MB,KB或者GB的格式返回 function CalcFullDatabaseSize($database, $db) { $tables = mysql_list_tables($database, $db); if (!$tables) { return -1; } $table_count = mysql_num_rows($tables); $size = 0; for ($i=0; $i
Time of Update: 2016-07-25
function num_format($num){if(!is_numeric($num)){return false;}$rvalue='';$num = explode('.',$num);//把整數和小數分開$rl = !isset($num['1']) ? '' : $num['1'];//小數部分的值$j = strlen($num[0]) % 3;//整數有多少位$sl = substr($num[0], 0, $j);//前面不滿三位的數取出來$sr = substr($num[
Time of Update: 2016-07-25
處理代碼: header('Content-Type:text/html;charset=UTF-8'); //準備接收 /* echo '檔案名稱:'.$_FILES['userfile']['name']; echo '檔案大小:'.$_FILES['userfile']['size']; echo '錯誤:'.$_FILES['userfile']['error']; */
Time of Update: 2016-07-25
test();/** * 測試 */function test() { echo CnToInt('一'); // 1 echo CnToInt('十'); // 10 echo CnToInt('十一'); // 11 echo CnToInt('一百一十'); // 110 echo CnToInt('一千零一'); // 1001 echo CnToInt('一萬零一百零一'); // 10101 echo
Time of Update: 2016-07-25
require './class.phpmailer.php';$mail=new
Time of Update: 2016-07-25
$handle = @ fopen ( "demo.txt" , "r" ); if ( $handle ) { while (( $buffer = fgets ( $handle , 4096 )) !== false ) { echo $buffer ; } if (! feof ( $handle )) { echo "Error: unexpected
Time of Update: 2016-07-25
if(strpos($_SERVER["HTTP_USER_AGENT"],"MSIE 8.0")) echo "Internet Explorer 8.0"; // 這裡可以寫其他的執行命令 else if(strpos($_SERVER["HTTP_USER_AGENT"],"MSIE 7.0")) echo "Internet Explorer 7.0"; else
Time of Update: 2016-07-25
通過使用此程式碼片段,您可以很容易地提取任何網頁上的所有連結。 $html = file_get_contents('http://www.example.com'); $dom = new DOMDocument(); @$dom->loadHTML($html); // grab all the on the page $xpath = new DOMXPath($dom); $hrefs = $xpath->
Time of Update: 2016-07-25
/** * 獲得檔案的mime type類型 * @author xiaobing.meng * */class MimeTypes {public static $mime_types = array ('apk' => 'application/vnd.android.package-archive','3gp' => 'video/3gpp', 'ai' => 'application/postscript', 'aif' => 'audio/x-aiff',
Time of Update: 2016-07-25
function send_mail ($title,$content,$from,$to,$charset='gbk',$attachment =''){ include '/class/PHPMail.class.php'; //百度兩下 header('Content-Type: text/html; charset='.$charset); $mail = new PHPMailer(); $mail->CharSet =
Time of Update: 2016-07-25
/** * 匯出資料為excel表格 *@param $data 一個二維數組,結構如同從資料庫查出來的數組 *@param $title excel的第一列名,一個數組,如果為空白則沒有標題 *@param $filename 下載的檔案名稱 *@examlpe $stu = M ('User'); $arr = $stu -> select(); exportexcel($arr,array('id','賬戶','密碼','暱稱')
Time of Update: 2016-07-25
function download_file($file){if(is_file($file)){$length = filesize($file);$type = mime_content_type($file);$showname = ltrim(strrchr($file,'/'),'/');header("Content-Description: File Transfer");header('Content-type: ' .
Time of Update: 2016-07-25
關於PHP產生認證密鑰的資料真是好少啊,查了半天,最終還是在官方文檔找到了相關資料,又根據自己的理解,整理成了以下代碼,分成兩部分:產生認證密鑰、加密解密資料。直接複製下來做成兩個檔案運行就好啦。已經寫了詳細的注釋,相信php程式員都能看得懂。 generate.php $dn = array( "countryName" => 'XX', //所在國家名稱 "stateOrProvinceName" => 'State',