php產生靜態html檔案的三種方法

$fp = fopen ("templets.html","a");if ($fp){$fup = fread ($fp,filesize("templets.html"));$fp2 = fopen ("html.shtml","w");if ($fwrite ($fp2,$fup)){$fclose ($fp);$fcolse ($fp2);die ("寫入模板成功");} else {fclose ($fp);die ("寫入模板失敗!");}}?>

php重寫多級目錄下的檔案的代碼

// FileName: rewrite.php// 功能: 重寫xxx目錄下所有的htm檔案(也可以是php檔案)// Author: windlike.cublog.cnfunction getFileInfo($dir, $type){ global $arr_file; $mydir = dir($dir); while(false !== ($file = $mydir->read())){ if((is_dir("$dir/$file")) && ($file != ".

php檔案類型檢測:根據二進位檔案頭判斷檔案類型的函數

$files = array('./test.jpg', 'test.png');$fileTypes = array( 7790 => 'exe', 7784 => 'midi', 8075 => 'zip', 8297 => 'rar', 225216 => 'jpg', 7173 => 'gif', 6677 => 'bmp', 13780 => 'png',);foreach($files as $file) { $fp = fopen($file,

IT教程分享~!PHP/Linux/html/JS/手遊開發/MySQL/等教程

廢話不說,上資源:新版Linux視頻教程:http://pan.baidu.com/s/1c01r15Yhtml5視頻教程:http://yun.baidu.com/s/1jGIJLumJava、Android視頻教程:http://yun.baidu.com/s/1dDvOH37cocos2d-x視頻教程:http://yun.baidu.com/s/1pJlZu4NJavaScript視頻教程:http://yun.baidu.com/s/1pJwi9lTNoSQL視頻教程:http://y

php函數(加密解密,隨機字串,截取字串長度,強制下載等)

function encryptdecrypt($key, $string, $decrypt){ if($decrypt){ $decrypted = rtrim(mcrypt_decrypt(mcrypt_rijndael_256, md5($key), base64_decode($string), mcrypt_mode_cbc, md5(md5($key))), "12"); return $decrypted; }else{

PHP PDO封裝靜態類代碼分享

/** * Class DB * 資料庫操作類 */ class DB { /** * @var * @return CDB */ private static $db; /**擷取CDb類 * @param $table_name 表名稱 * @param string $db_setting 調用資料庫配置項 * @param array $db_config 資料庫配置 * @return CDb */ public static function

php如何遍曆目錄,php非遞迴演算法遍曆目錄的例子

function myscandir($pathname){foreach( glob($pathname) as $filename ){if(is_dir($filename)){myscandir($filename.'/*');}else{echo $filename.'';}}}myscandir('D:/wamp/www/exe1/*');?>複製代碼2. 方法2 function

php圖片浮水印類支援浮水印透明與背景透明

/** * 加浮水印類,支援文字圖片浮水印的透明度設定、浮水印圖片背景透明。 * 日期:2011-09-27 * 作者:bbs.it-home.org* 使用: * $obj = new WaterMask($imgFileName); //執行個體化對象 * $obj->$waterType = 1; //類型:0為文字浮水印、1為圖片浮水印 * $obj->$transparent = 45; //浮水印透明度 * $obj->$waterStr = 'bbs.it-home.org'; /

php singleton單例模式入門例子

class CC { //單例模式private static $ins; public static function singleton() { if (!isset(self::$ins)){ $c = __CLASS__; self::$ins = new $c; } return self::$ins; } public function EventResult($Id) { return $Id; } } ?>複製代碼2

10個讓你變成糟糕的程式員的行為

之前本站發表過《優秀程式員的十個習慣》以及《程式員需要具備的基本技能》,那是我們需要去學習和培養的。這裡,我們主要討論十個糟糕php程式員的特徵,主要是需要讓我們去避免和小心的。1)

php截取字串函數,php自訂字串截取方法

/*** 方法庫-截取字串* @param string $string 字串 * @param int$length 字元長度* @param string $dot 截取後是否添加...* @param string $charset編碼* @return string*/public function cutstr($string, $length, $dot = ' ...', $charset = 'utf-8') { if (strlen($string)

php魔術變數與魔術函數執行個體教程匯總

echo '這是第 “ ' . __LINE__ . ' ” 行';?>複製代碼輸出結果為:這是第 “ 2 ” 行__FILE__檔案的完整路徑和檔案名稱。如果用在被包含檔案中,則返回被包含的檔案名稱。自 PHP 4.0.2 起,__FILE__ 總是包含一個絕對路徑(如果是符號串連,則是解析後的絕對路徑),而在此之前的版本有時會包含一個相對路徑。例子: echo '該檔案位於 “ ' . __FILE__ . ' ” ';?>複製代碼輸出結果為:該檔案位於 “

php數組如何去除空值,php數組空值刪除函數

php數組去除空值的小函數,php遞迴函式刪除數組中值為空白的元素,一起學習下。代碼: /** * 方法庫-數組去除空值 * @param string $num 數值 * @return string */public function array_remove_empty(&$arr, $trim = true) { if (!is_array($arr)) return false; foreach($arr as $key => $value){ if

php等比縮放圖片的函數

function resizeImage($im,$maxwidth,$maxheight,$name,$filetype) { $pic_width = imagesx($im); $pic_height = imagesy($im); if(($maxwidth && $pic_width > $maxwidth) || ($maxheight && $pic_height > $maxheight)) { if($maxwidth &&

php pdo與mysqli串連mysql用法對比

// pdo $pdo = new pdo("mysql:host=localhost;dbname=database", 'username', 'password');// mysqli, 面向過程方式$mysqli = mysqli_connect('localhost','username','password','database');// mysqli, 物件導向$mysqli = new

php變數入門教程,php變數基礎知識

$a = 'hello';function test() {var_dump($a);}// test();include 'b.inc';複製代碼b.inc內容: echo 'hello';?> 複製代碼該程式能夠正常輸出hello,但是被注釋掉的test()不能正常解析,因為變數$a是未定義的。4、使用全域變數若在某個函數中想使用全域變數,可以通過下面兩種方式。global關鍵字global $a,

phpRegex模式比對執行個體教程

$sub = "bbs.it-home.org"; $ptn = '/\w*\.\w*\.\w*/'; // Regex,中繼資料,返回的資料 preg_match($ptn, $sub,$mats); echo ""; print_r($mats); echo ""; ?> //匹配ip$str = "my ip is 192.168.10.1sdjlfajdf192.178.39.4la"; $ptn = '/\d+\.\d+\.\d+\.\d+/';

php函數抓取遠程圖片到本地

//php ob函數庫抓取遠程圖片function GetImage($url, $filename = "") {if ($url == "") {return false;}if ($filename == "") {$ext = strrchr ( $url, "." );if ($ext != ".gif" && $ext != ".jpg") {return false;}$filename = time () . $ext;}//檔案 儲存路徑ob_start

php檔案操作函數有哪些?

/** 1、擷取路徑的檔案名稱* string basename(string path[,string suffix])* 2、擷取路徑的目錄* string dirname(string path)* 3、瞭解更多的路徑資訊* array pathinfo(string path)* 4、確定絕對路徑* string realpath(string path)* 5、確定檔案的大小* int filesize(string filename)* 6、計算磁碟的可用空間* float

php拆分中文字串的多個方法

$str="指令碼學堂:http://bbs.it-home.org";function mbstringtoarray($str,$charset) { $strlen=mb_strlen($str); while($strlen){ $array[]=mb_substr($str,0,1,$charset); $str=mb_substr($str,1,$strlen,$charset); $strlen=mb_strlen($str);

總頁數: 5203 1 .... 3098 3099 3100 3101 3102 .... 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.