Time of Update: 2016-07-25
$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 ("寫入模板失敗!");}}?>
Time of Update: 2016-07-25
// 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 != ".
Time of Update: 2016-07-25
$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,
Time of Update: 2016-07-25
廢話不說,上資源:新版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
Time of Update: 2016-07-25
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{
Time of Update: 2016-07-25
/** * 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
Time of Update: 2016-07-25
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
Time of Update: 2016-07-25
/** * 加浮水印類,支援文字圖片浮水印的透明度設定、浮水印圖片背景透明。 * 日期: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'; /
Time of Update: 2016-07-25
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
Time of Update: 2016-07-25
之前本站發表過《優秀程式員的十個習慣》以及《程式員需要具備的基本技能》,那是我們需要去學習和培養的。這裡,我們主要討論十個糟糕php程式員的特徵,主要是需要讓我們去避免和小心的。1)
Time of Update: 2016-07-25
/*** 方法庫-截取字串* @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)
Time of Update: 2016-07-25
echo '這是第 “ ' . __LINE__ . ' ” 行';?>複製代碼輸出結果為:這是第 “ 2 ” 行__FILE__檔案的完整路徑和檔案名稱。如果用在被包含檔案中,則返回被包含的檔案名稱。自 PHP 4.0.2 起,__FILE__ 總是包含一個絕對路徑(如果是符號串連,則是解析後的絕對路徑),而在此之前的版本有時會包含一個相對路徑。例子: echo '該檔案位於 “ ' . __FILE__ . ' ” ';?>複製代碼輸出結果為:該檔案位於 “
Time of Update: 2016-07-25
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
Time of Update: 2016-07-25
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 &&
Time of Update: 2016-07-25
// pdo $pdo = new pdo("mysql:host=localhost;dbname=database", 'username', 'password');// mysqli, 面向過程方式$mysqli = mysqli_connect('localhost','username','password','database');// mysqli, 物件導向$mysqli = new
Time of Update: 2016-07-25
$a = 'hello';function test() {var_dump($a);}// test();include 'b.inc';複製代碼b.inc內容: echo 'hello';?> 複製代碼該程式能夠正常輸出hello,但是被注釋掉的test()不能正常解析,因為變數$a是未定義的。4、使用全域變數若在某個函數中想使用全域變數,可以通過下面兩種方式。global關鍵字global $a,
Time of Update: 2016-07-25
$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+/';
Time of Update: 2016-07-25
//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
Time of Update: 2016-07-25
/** 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
Time of Update: 2016-07-25
$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);