Time of Update: 2016-07-25
function CreateImage($SrcImageUrl, $DirImageUrl, $Width, $Height){$img;$srcw;$new_width;$srch;$new_height;// 圖片類型$type = substr(strrchr($SrcImageUrl, "."), 1);// 初始化映像 if($type == "jpg") $img = imagecreatefromjpeg($SrcImageUrl); if($type == "gif")
Time of Update: 2016-07-25
本文介紹下,在php中去除bom頭的執行個體代碼,bom在檔案頭部,佔用三個位元組,有時需要去除這些資訊。本文給出的樣本,大家可以作個參考。去除bom頭的php代碼,如下:";}else{$dirname = $basedir."/".$file;checkdir($dirname);}}}closedir($dh);}}function checkBOM ($filename) {global $auto;$contents =
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
本文介紹了php遞迴函式中傳回值的正確用法,php遞迴函式中使用return傳回值需要注意哪些問題,以加深對php遞迴函式的理解。php遞迴函式傳回值例子,php遞迴函式傳回值寫法。複製代碼 程式碼範例:0) { $n--; return sum($n,$s); }else{ return $s; } } $sum = 0; echo
Time of Update: 2016-07-25
function getImageInfo($img){ //$img為圖象檔案絕對路徑,例如,D:\iamge\jn0-541.gif$img_info=getimagesize($img); switch($img_info[2]){ case1: $imgtype="GIF"; break; case2: $imgtype="JPG"; break; case3: $imgtype="PNG"; break; } $img_type=$imgtype."映像";
Time of Update: 2016-07-25
/* * php自動產生新密碼自訂函數(帶執行個體示範) 適用環境: PHP5.2.x / mysql 5.0.x 代碼作者: xujiajay 連絡方式: xujiaphp@gmail.com* */function genPassword($min = 5, $max = 8) { $validchars="abcdefghijklmnopqrstuvwxyz123456789";
Time of Update: 2016-07-25
session_start(); if (empty($page)) {$page=1;} if (isset($_GET['page'])==TRUE) {$page=$_GET['page']; }?> Read Result if($page){ $counter=file_get_contents("example.txt"); //讀取txt檔案內容到$counter$length=strlen($counter); $page_count=ceil($
Time of Update: 2016-07-25
ini_set('memory_limit', '-1'); /*檢測並清除BOM*/ $basedir = dirname(__FILE__);//掃描當前檔案路徑 可自動化佈建 $auto = 1; checkdir($basedir); function checkdir($basedir){ if($dh = opendir($basedir)){ while(($file = readdir($dh)) !== false){
Time of Update: 2016-07-25
/** 功 能: 檔案下載*//*** 使用方法:$download = new Download();* //設定參數* $download->set_file_dir("c:/");* $download->set_file_name("boot.ini");* $download->set_read_bytes(1024);* //檔案下載處理操作* $download->deal_with(); * //判斷檔案是否存在* if($download->is_file_exist()){*
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
function toFixLen($str,$len){ //固定長度字串的截取if($len>=strlen($str)||!$len)return$str; $len-=3; $tempstr1=substr($str,0,$len); //截取字串 $tempstr2=preg_replace('/([\x81-\xff]+)$/ms','',$tempstr1,1); //去掉結尾的連續漢字字元 if(!is_int((strlen($tempstr1)-strlen(
Time of Update: 2016-07-25
在php遞迴函式中,經常會遇到遞迴函式無傳回值的問題,那麼在php實現的遞迴中如何正確處理傳回值呢,php遞迴函式無傳回值怎麼辦,可以參考下本文的執行個體分析。一、php遞迴函式的傳回值例1: 複製代碼 程式碼範例:function test($i){ $i-=4; if($itest($i); }}echo test(30)." ";注意,以上代碼中else內裡是有問題的,條件$i例2,修改php遞迴函式為: 複製代碼 程式碼範例:function test($i){ $i-=4; if(
Time of Update: 2016-07-25
$switching = array( 10, // key = 0 5 => 6, 3 => 7, 'a' => 4, 11, // key = 6 (整個數組中整型鍵索引最大的值是5) '8' => 2, // key = 8 (字串健'8'轉換為8) '02' => 77, // key = '02'(注意不是2) 0 => 12 /*前面值為10的鍵被賦予0,而後面重新定義了0鍵的值為12, 從而覆蓋了前面預設的0索引值*/ );// empty array$
Time of Update: 2016-07-25
使用php遞迴函式正確刪除非空目錄的方法,php目錄與檔案的刪除方法,當遇到非空目錄時,考慮用php遞迴實現目錄遍曆與刪除,是個不錯的選擇。php遞迴函式遞迴刪除目錄的思路:1、php遞迴遍曆目錄及子目錄2、使用 scandir 判斷目錄是否為空白,為空白則使用rmdir 刪除。例子,php遞迴函式 刪除所有空目錄:複製代碼 程式碼範例: 使用 shell 則簡單很多: find 目標檔案夾 -mindepth 1 -depth -empty -type d -exec rm -r {}
Time of Update: 2016-07-25
在調試 PHP 應用程式時,應當知道兩個組態變數。下面是這兩個變數及其預設值:display_errors = Off error_reporting = E_ALL開啟PHP的錯誤報表的方法,供大家參考。php.ini 檔案中有許多配置設定。您應當已經設定好自己的 php.ini 檔案並把它放在合適的目錄中,就像在 Linux 上安裝 PHP 和 Apache 2 的文檔說明中所示的那樣。在調試 PHP
Time of Update: 2016-07-25
/*** 過濾頁面中bom* edit bbs.it-home.org*/function checkBOM ($filename) {$contents = file_get_contents($filename);$charset[1] = substr($contents, 0, 1);$charset[2] = substr($contents, 1, 1);$charset[3] = substr($contents, 2, 1);if (ord($charset[1]) == 239
Time of Update: 2016-07-25
php怎麼查看目錄大小等資訊,php如何複製目錄與刪除檔案,php遞迴刪除目錄與子目錄的自訂函數代碼,可以遞迴查詢目錄中的檔案大小,從而統計出目錄大小。一、php目錄函式遞迴查詢目錄中的檔案大小,從而統計出目錄大小。 複製代碼 程式碼範例:二、php目錄函式帶二個參數這個函數需要傳遞兩個url,分別是舊目錄和新目錄,就能複製該目錄及檔案例子: 複製代碼 程式碼範例:三、php目錄函式三帶一個參數這個函數只要傳遞一個url,就能遞迴刪除目錄及子目錄的檔案,從而刪除目錄。例子: 複製代碼
Time of Update: 2016-07-25
有關php遞迴函式傳回值問題的解決方案,以及php遞迴函式中使用return語句傳回值時,要注意的一些要點,正確處理php遞迴函式的傳回值,使代碼更健壯。php遞迴函式的傳回值問題例子: 複製代碼 程式碼範例: 在以上代碼中else裡面是有問題的。在這裡執行的test沒有傳回值。所以雖然滿足條件$i對上面的php遞迴函式做如下修改:複製代碼
Time of Update: 2016-07-25
/* * PHP code to export MySQL data to CSV * * Sends the result of a MySQL query as a CSV file for download * Easy to convert to UTF-8. */ /* * establish database connection */ $conn = mysql_connect('localhost', 'login', 'pass') or die(mysql_error()
Time of Update: 2016-07-25
/*** 遞迴法實現的快速排序*/function quicksort($seq){$k = $seq[0];$x = array();$y = array();for($i=1; $iif($seq[$i] $x[] = $seq[$i];} else {$y[] = $seq[$i];}}$x = quicksort($x);$y = quicksort($y);return array_merge($x, array($k), $y);} else {return $seq;}}複製代碼2