PHP實現壓縮html的函數

function compress_html($string) { $string = str_replace("\r\n", '', $string); //清除分行符號 $string = str_replace("\n", '', $string); //清除分行符號 $string = str_replace("\t", '', $string); //清除定位字元 $pattern = array ( "/> *([^ ]*

PHP實現遞迴建立多級目錄的通用方法

/** * +-------------------------------------------------------------------- * Description 遞迴建立目錄 +-------------------------------------------------------------------- * @param string $dir 需要創新的目錄 +----------------------------------------------------

PHP實現擷取中文的首頁字母方法

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

php把一個顏色變深的函數

這個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 =

PHP實現下載圖片的通用方法

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 =

PHP實現資料分頁的通用方法

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 =

PHP實現用迭代實現數組的快速排序

function quicksortX(&$seq){ $stack = array($seq); $sort = array(); while ($stack) { $arr = array_pop($stack); if(count($arr) if (count($arr) == 1) { $sort[] = &$arr[0]; }

php計算整個mysql資料庫的大小

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

PHP實現人民幣數字格式化,每三位加逗號

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[

PHP檔案上傳樣本

處理代碼: header('Content-Type:text/html;charset=UTF-8'); //準備接收 /* echo '檔案名稱:'.$_FILES['userfile']['name']; echo '檔案大小:'.$_FILES['userfile']['size']; echo '錯誤:'.$_FILES['userfile']['error']; */

PHP實現漢字轉整型數字,如:一百零一 轉成101

test();/** * 測試 */function test() { echo CnToInt('一'); // 1 echo CnToInt('十'); // 10 echo CnToInt('十一'); // 11 echo CnToInt('一百一十'); // 110 echo CnToInt('一千零一'); // 1001 echo CnToInt('一萬零一百零一'); // 10101 echo

PHPMailer發送郵件

require './class.phpmailer.php';$mail=new

PHP檔案讀寫

$handle = @ fopen ( "demo.txt" , "r" ); if ( $handle ) { while (( $buffer = fgets ( $handle , 4096 )) !== false ) { echo $buffer ; } if (! feof ( $handle )) { echo "Error: unexpected

php禁止用下載工具來下載檔案

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

PHP取得一個頁面中的所有連結

通過使用此程式碼片段,您可以很容易地提取任何網頁上的所有連結。 $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->

PHP獲得檔案的mime type類型

/** * 獲得檔案的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',

用PHPMail類發送郵件

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 =

PHP實現匯出Excel檔案通用方法

/** * 匯出資料為excel表格 *@param $data 一個二維數組,結構如同從資料庫查出來的數組 *@param $title excel的第一列名,一個數組,如果為空白則沒有標題 *@param $filename 下載的檔案名稱 *@examlpe $stu = M ('User'); $arr = $stu -> select(); exportexcel($arr,array('id','賬戶','密碼','暱稱')

PHP實現簡單的檔案下載通用方法

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: ' .

PHP通過OpenSSL產生認證、密鑰並且加密解密資料

關於PHP產生認證密鑰的資料真是好少啊,查了半天,最終還是在官方文檔找到了相關資料,又根據自己的理解,整理成了以下代碼,分成兩部分:產生認證密鑰、加密解密資料。直接複製下來做成兩個檔案運行就好啦。已經寫了詳細的注釋,相信php程式員都能看得懂。 generate.php $dn = array( "countryName" => 'XX', //所在國家名稱 "stateOrProvinceName" => 'State',

總頁數: 5203 1 .... 3106 3107 3108 3109 3110 .... 5203 Go to: 前往

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.