Time of Update: 2016-07-25
if (!is_dir('img')) { mkdir('img'); }複製代碼> 3、用正則式把圖片相對位址取出來: if (preg_match('/^http.*/',$val)) { $target = $val; } else if (preg_match('/^\/.*/',$val)) { $target=$host.$val; } else { $target=$url.$val; } echo $target."\r\n";複製代碼> 最後把檔案名稱取出來,即 /img/1
Time of Update: 2016-07-25
有關php header跳轉失效的解決方案,header跳轉頁面時的一些注意事項,若一定要在輸出之後再處理header資訊,可以使用 ob_start() ob_end_flush() 來緩衝內容。php header跳轉失效的解決方案一、問題:header(\"location: $url\")跳轉失敗,只是輸出結果,以往要確認檢查,$url的值擷取的是否正確,所以在前面加了echo
Time of Update: 2016-07-25
有關php圖片上傳與php加浮水印的執行個體代碼,一個完整的php上傳圖片的例子,需要的朋友參考下。1、send.html File Uploader File Upload Select a file to upload: 2,接收 img_receive.php 檔案名稱: ".$destination_folder.$fname.""; echo " 寬度:".$image_size[0]; echo "
Time of Update: 2016-07-25
/** *@阿唐 2013-4-6 22:19 *@呵呵 */ set_time_limit(0); error_reporting(E_ERROR); if($argcprint_r(' +-------------------------------------------------+ Usage: php '.$argv[0].' css路徑類型(0為遠程、1為本地) css檔案路徑 圖片儲存目錄 Example:
Time of Update: 2016-07-25
有關php儲存二進位未經處理資料為圖片檔案的方法,接收post過來的二進位未經處理資料,選擇一個產生路徑及圖片的名字,之後寫入,需要的朋友參考下。例子,php儲存二進位未經處理資料為圖片檔案。//產生圖片 $imgDir = 'uploadImg/'; $filename="nissangcj".$mobile.".jpg"; ///要產生的圖片名字 $xmlstr = $GLOBALS[HTTP_RAW_POST_DATA]; if(empty($xmlstr)) { $xmlstr
Time of Update: 2016-07-25
/** * TODO 基礎分頁的相同代碼封裝,使前台的代碼更少 * @param $m 模型,引用傳遞 * @param $where 查詢條件 * @param int $pagesize 每頁查詢條數 * @return \Think\Page */function getpage(&$m,$where,$pagesize=10){ $m1=clone $m;//淺複製一個模型 $count =
Time of Update: 2016-07-25
/*** php分頁類代碼* edit: bbs.it-home.org*/class Page { private $total; //總記錄 private $pagesize;//每頁顯示多少條 private $limit; //limit private $page; //當前頁碼 private $pagenum; //總頁碼 private $url; //地址 private $bothnum; //兩邊保持數字分頁的量
Time of Update: 2016-07-25
一個用於php二維數組排序的自訂函數,分享一下,有用到的朋友看看吧。代碼如下:$v){ $keysvalue[$k] = $v[$keys]; } if($type == 'asc'){ asort($keysvalue); }else{ arsort($keysvalue); } reset($keysvalue); foreach ($keysvalue as $k=>$v){ $new_array[$k] =
Time of Update: 2016-07-25
private function _addEtag($file) { $last_modified_time = filemtime($file); $etag = md5_file($file); // always send headers header("Last-Modified: ".gmdate("D, d M Y H:i:s", $last_modified_time)." GMT"); header("Etag: $etag"); //
Time of Update: 2016-07-25
//擷取要清楚的目錄和目錄所在的絕對路徑 public function cache(){ ////前台用ajax get方式進行提交的,判斷下 if($_POST['type']){ //得到傳遞過來的值 $type=$_POST['type']; //將傳遞過來的值進行切割,我是用“-”進行切割的 $name=explode('-', $type); //得到切割的條數,便於下面迴圈 $count=count($name); //迴圈調用上面的方法
Time of Update: 2016-07-25
在mysql資料庫中插入帶有單引號或雙引號的字串時,如果是單個字串,可以考慮用反斜線進行轉義,如果是大批量的資料需要轉換呢,又該怎麼辦呢?參考下本文中的介紹吧。如果有大量的內容需要轉義,可以考慮mysql_real_escape_string函數:mysql_real_escape_string — 轉義 SQL 陳述式中使用的字串中的特殊字元,並考慮到串連的當前字元集。注意:該函數並不轉義 % 和
Time of Update: 2016-07-25
複製代碼class SubPages{ private $each_disNums;//每頁顯示的條目數 private $nums;//總條目數 private $current_page;//當前被選中的頁 private $sub_pages;//每次顯示的頁數 private $pageNums;//總頁數 private $point;//總頁數 private $page_array = array();//用來構造分頁的數組
Time of Update: 2016-07-25
$data[] = array('volume' => 67, 'edition' => 2);$data[] = array('volume' => 86, 'edition' => 1);$data[] = array('volume' => 85, 'edition' => 6);$data[] = array('volume' => 98, 'edition' => 2);$data[] = array('volume' => 86, 'edition' => 6);$data[] =
Time of Update: 2016-07-25
static function getMenuTree($arrCat, $parent_id = 0, $level = 0,$all=True){static $arrTree; //使用static代替globalif(!$all) $arrTree ='';if( empty($arrCat)) return FALSE;$level++;if($level == 1) $arrTree[] = $parent_id;foreach($arrCat as $key => $value)
Time of Update: 2016-07-25
php;toolbar:false">/*public function actionReport(){$sql = "select * from {{goods}}";$criteria=new CDbCriteria();$result = Yii::app()->db->createCommand($sql)->query();$pages=new
Time of Update: 2016-07-25
function guid(){if (function_exists('com_create_guid')){return com_create_guid();}else{mt_srand((double)microtime()*10000);//optional for php 4.2.0 and up.$charid = strtoupper(md5(uniqid(rand(), true)));$hyphen = chr(45);// "-"$uuid = chr(123)// "{".
Time of Update: 2016-07-25
define("ANGLE_STEP", 5); //定義畫橢圓弧時的角度步長 function draw_getdarkcolor($img,$clr) //求$clr對應的暗色 { $rgb = imagecolorsforindex($img,$clr); return array($rgb["red"]/2,$rgb["green"]/2,$rgb["blue"]/2); } function draw_getexy($a, $
Time of Update: 2016-07-25
class DataCache { /** * 數群組轉換 * * @param array $array * @param string $arrayName * @param array $level * * @return string */ private function arrayEval($array, $arrayName = '', $level = 0) { $space = str_repeat("t", $level);
Time of Update: 2016-07-25
function selected ( $param , $value ) { if ( $param == $value ) print "SELECTED" ; } # Collect any form data to control the display $scale = 10 ; $maptype = "G_NORMAL_MAP" ; if ( $_REQUEST [ scale ]) $scale = $_REQUEST [ scale ]; if (
Time of Update: 2016-07-25
/** mysql分頁函數代碼* edit:bbs.it-home.org* */function page($page,$total,$phpfile,$pagesize=10,$pagelen=7){ $pagecode = '';//定義變數,存放分頁產生的HTML $page = intval($page);//避免非數字頁碼 $total = intval($total);//保證總記錄數實值型別正確 if(!$total) return array();//總記錄數為零返回空數組 $