Time of Update: 2016-07-25
/*** 功能:隨機顯示圖片* Filename : img.php* Usage:* * * Edit: bbs.it-home.org**/ if($_GET['folder']){ $folder=$_GET['folder']; }else{ $folder='/images/'; } //存放圖片檔案的位置 $path = $_SERVER['DOCUMENT_ROOT']."/".$folder;
Time of Update: 2016-07-25
[Session]; Handler used to store/retrieve data.session.save_handler = files ;
Time of Update: 2016-07-25
/*** php簡單日曆* edit: bbs.it-home.org*/if(empty($year))$year=date("Y"); //初始化年份 if(empty($month))$month=date("n"); //初始化月份 $wd_ar=array("日","一","二","三","四","五","六"); //星期數組 $wd=date("w",mktime(0,0,0,$month,1,$year)); //當月第一天是星期幾//年連結
Time of Update: 2016-07-25
複製代碼2,刪除一組檔案的代碼 process.php # Take each checked value, and give it a name of $deleteforeach($_POST['delete'] as $delete){ # Make sure the file actually exists if(file_exists("/location/of/directory/".$delete)){ # Delete each file
Time of Update: 2016-07-25
function build_calendar($month,$year,$dateArray) { // 日曆表頭,星期天開始一直到星期六 $daysOfWeek = array('S','M','T','W','T','F','S'); // 本月第一天的位置 $firstDayOfMonth = mktime(0,0,0,$month,1,$year); // 擷取本月天數 $numberDays = date('t',$firstDayOfMonth); // 擷取本月第一天
Time of Update: 2016-07-25
// 擷取檔案夾大小 function getDirSize($dir) { $handle = opendir($dir); while (false!==($FolderOrFile = readdir($handle))) { if($FolderOrFile != "." && $FolderOrFile != "..") {
Time of Update: 2016-07-25
$url = 'http://example.com'; $hander_array = get_headers ( $url ); if ($header_array [0] == 'HTTP/1.1 200 OK') { echo '檔案存在'; } else { echo '檔案不存在'; }
Time of Update: 2016-07-25
/** * php日曆 * by bbs.it-home.org*/ if (function_exists('date_default_timezone_set')) { date_default_timezone_set('Asia/Chongqing'); } $date = isset($_GET['date']) ? $_GET['date'] : date('Y-m-d'); $date = getdate(strtotime($date)); $end =
Time of Update: 2016-07-25
/*** mysql讀寫分離* edit: bbs.it-home.org*/class db { public function __construct($sql) { $chestr = strtolower(trim($sql)); //判斷sql語句有select關鍵字的話,就串連讀的資料庫,否則就串連寫資料庫 if(substr($chestr,0,6)=='select') {
Time of Update: 2016-07-25
error_reporting(E_ALL);ini_set('display_errors', '1');//將出錯資訊輸出到一個文字檔ini_set('error_log', dirname(__FILE__) . '/error_log.txt'); 複製代碼更多有關error_reporting的內容,請參考:php中error_reporting()函數的用法參考教你開啟PHP的error_log日誌的方法php
Time of Update: 2016-07-25
/*** 讀取目錄列表的函數* edit: bbs.it-home.org*/function GetFolders( $resourceType, $currentFolder ){ // Map the virtual path to the local server path. $sServerDir = ServerMapFolder( $resourceType, $currentFolder, 'GetFolders' ) ; // Array that will hold the
Time of Update: 2016-07-25
/*** 讀取檔案夾及其中檔案的函數* edit: bbs.it-home.org**/function GetFoldersAndFiles( $resourceType, $currentFolder ){ // Map the virtual path to the local server path. $sServerDir = ServerMapFolder( $resourceType, $currentFolder, 'GetFoldersAndFiles' ) ; //
Time of Update: 2016-07-25
/* 遍曆檔案夾; 功能:(a)可刪除檔案 (b)可編輯文本,網頁檔案 (c)可刪除檔案夾,前提是該檔案夾為空白 (d)可建立檔案,檔案夾,修改檔案夾名稱; */ $path=$DOCUMENT_ROOT; $path=str_replace("/","\\",$path); //指定檔案夾 $path=$path."\\"; if($_GET['folder']) { $path.=$_GET['folder']."\\"; } //本頁面路徑,下面傳回時將用到; $url=$_SERVER[
Time of Update: 2016-07-25
/*** 去除數組中重複值的函數* by bbs.it-home.org*/function array_assoc_unique($arr, $key) { $tmp_arr = array(); foreach($arr as $k => $v) { if(in_array($v[$key], $tmp_arr)) { unset($arr[$k]); } else { $tmp_arr[] = $v[$key];
Time of Update: 2016-07-25
/*** 使用JpGraph產生柱狀圖* by bbs.it-home.org*/ require_once '../jpgraph/src/jpgraph.php'; require_once '../jpgraph/src/jpgraph_line.php'; require_once '../jpgraph/src/jpgraph_bar.php'; // y 軸資料,以數組形式賦值 $ydata = array(12,4,9,15,11,10,9,7,15,7); //
Time of Update: 2016-07-25
/*** php 檔案上傳* 2013-11-30*/if($_POST[sub]){if(is_uploaded_file($_FILES[file][tmp_name])){//判斷是否取到臨時檔案,並儲存php內部。傳回值為1為真。$file=$_FILES[file];print_r($file); // bbs.it-home.org$name=$file[name];$tmp=$file[tmp_name];$size=$file[size];$error=$file[error];
Time of Update: 2016-07-25
php函數指定預設值-bbs.it-home.orgfunction printMe($param = NULL){ print $param;}printMe("This is test");printMe();?> 複製代碼輸出結果:This is test例2,php函數參數預設值的使用範例,php函數參數中設定和使用預設值。代碼: php函數參數預設值 - bbs.it-home.org function textonweb ($content,
Time of Update: 2016-07-25
//url形式function embSwfWithUrl(dataurl,divcon){ var params = { "wmode": "transparent", "menu": "false", "scale": "noScale", "allowFullscreen": "false", "allowScriptAccess": "always", "bgcolor": "#c0c0c0"
Time of Update: 2016-07-25
/** * 返回數組的維度 * @param [type] $arr [description] * @return [type] [description] */ bbs.it-home.orgfunction arrayLevel($arr){ $al = array(0); function aL($arr,&$al,$level=0){ if(is_array($arr)){ $level++;
Time of Update: 2016-07-25
/*** 圖片上繪製正餘弦曲線的方法* edit:bbs.it-home.org*/ define("MAX_WIDTH_PIXEL", 600); define("MAX_HEIGHT_PIXEL", 240); //發送標題資訊 header("Content-type: image/gif"); //建立映像 $img = imageCreate(MAX_WIDTH_PIXEL, MAX_HEIGHT_PIXEL); //設定顏色 $bgcolor =