Time of Update: 2016-07-25
$html = HTML; $ver = '1.0.3';$p = "/(
Time of Update: 2016-07-25
function overlayjpg($imgsrc,$imgdst,$width,$height=""){//$imgsrc jpg格式映像路徑 $imgdst jpg格式映像儲存檔案名稱 $imgwidth要改變的寬度 $imgheight要改變的高度//取得圖片的寬度,高度值$arr = getimagesize($imgsrc);//計算圖片X軸位置$img_X = ($width - $arr[0])/2;if($height == ""){ $heights = $arr[1
Time of Update: 2016-07-25
$str = preg_quote( “ /\d{3}(\-\d{4})/ ” ); echo $str; ?> 複製代碼結果:/\\d\{3\}\(\\\-\\d\{4\}\)/ 例2: $str = preg_quote( “ /\d{3}(\-\d{4})/ ” , ” 3 “ ); echo $str; ?> 複製代碼結果:/\\d\{\3\}\(\\\-\\d\{4\}\)/ 這兩個例子的區別:就是紅色地區中的 “ 3 ” ,在第二個例子中將 “ 3 ”
Time of Update: 2016-07-25
defaults('ADMIN_USERNAME','apc'); // Admin Usernamedefaults('ADMIN_PASSWORD','password'); // Admin Password - CHANGE THIS TO ENABLE!!!複製代碼3、apc使用樣本apc使用起來非常簡單,看下面的幾個增加、查詢、修改、刪除樣本。1)、增加一個緩衝,有效時間為3600秒apc_add('name', 'tom', 3600);執行代碼,然後查看User
Time of Update: 2016-07-25
/**php匯入csv檔案到資料庫****同時計算程式執行時間***///定義擷取時間函數 function getmicrotime(){ list($usec, $sec) = explode(" ",microtime()); return ((float)$usec + (float)$sec); }$time_start = getmicrotime();include("db.inc.php");//串連資料庫$db=new testcsv;$handle =
Time of Update: 2016-07-25
# tar xvzf zlib-1.2.3.tar.gz# cd zlib-1.2.3# ./configure# make && make install複製代碼3、安裝freetype # tar xvzf freetype-1.3.1.tar.gz# cd freetype-1.3.1# ./configure --prefix=/usr/local/freetype# make && make install 複製代碼有多行錯誤類似:ftdump.c:172:1: error:
Time of Update: 2016-07-25
;extension=php_dba.dll;extension=php_dbase.dll;extension=php_filepro.dll;extension=php_gd2.dll;extension=php_imap.dll;extension=php_mysql.dll 複製代碼接下來修改一些限制條件: memory_limit = 20Mpost_max_size = 20Mupload_max_filesize = 20M
Time of Update: 2016-07-25
//php排序函數執行個體function array_sort($arr,$keys,$type='asc'){ echo'開始排序...'.''; $keysvalue = $new_array = array(); foreach ($arr as $k=>$v) { $keysvalue[$k] = $v[$keys]; } if($type == 'asc') { asort($keysvalue); } else { arsort($keysvalue); } reset($
Time of Update: 2016-07-25
//在conf/php.ini中,在vim用"/php_mysql"搜尋到extension=php_mysql.dll,去掉前面的";",同時在下面增加extension=php_mysqli.dll;$mysqli = new mysqli("127.0.0.1","使用者名稱", 密碼","庫名");$query="select * from 表 order by theindex desc";$mysqli->query("set names gb2312");//注意此處不加會亂碼$
Time of Update: 2016-07-25
複製代碼2,檔案上傳類: public function img_upload(){ $this->load->helper('url'); $config['upload_path'] = './images/'.date('Ym', time()).'/'; $config['allowed_types'] = 'gif|jpg|png'; $config['file_name'] = date('Y_m_d', time()).'_'.sprintf('%02d', rand(0,99))
Time of Update: 2016-07-25
//php產生短網址function code62($x) {$show = '';while($x > 0) { $s = $x % 62; if ($s > 35) { $s = chr($s+61); } elseif ($s > 9 && $s $s = chr($s + 55); } $show .= $s; $x = floor($x/62);}return $show;} function shorturl($url) { $url = crc32(
Time of Update: 2016-07-25
/* * to change the template for this generated file go to * window - preferences - phpeclipse - php - code templates */ class student{ //屬性 private $no; private $name; private $gender; private $age; private static
Time of Update: 2016-07-25
/* PHP建立zip壓縮包 */function create_zip($files = array(),$destination = '',$overwrite = false) {//if the zip file already exists and overwrite is false, return falseif(file_exists($destination) && !$overwrite) { return false; }//vars$valid_files =
Time of Update: 2016-07-25
在php編程中,有關物件導向中有個函數稱為建構函式,是對象被建立時自動調用的方法,用來完成類初始化的工作。因為只要php的類一載入就會自動執行此函數,一般初始化的工作都放在此函數中。 1,建構函式和其它函數一樣,可以傳遞參數,可以設定參數預設值。 2,建構函式可以調用屬性,可以調用方法。 3,建構函式可以被其它方法顯式調用。
Time of Update: 2016-07-25
$content = iconv("gbk", "utf-8", $content); //第一種簡單易用$content = mb_convert_encoding($content, "utf-8", "gbk");//第二種避免出現意外複製代碼//發現iconv在轉換字元”—”到gb2312時會出錯,如果沒有ignore參數,所有該字元後面的字串都無法被儲存。不管怎麼樣,這個”—”都無法轉換成功,無法輸出。 另外mb_convert_encoding沒有這個bug.一般情況下用
Time of Update: 2016-07-25
function phpcharset($data, $to) {if(is_array($data)) {foreach($data as $key => $val) {$data[$key] = phpcharset($val, $to);}} else {$encode_array = array('ascii', 'utf-8', 'gbk', 'gb2312', 'big5');$encoded = mb_detect_encoding($data,
Time of Update: 2016-07-25
//將內容進行unicode編碼,編碼後的內容格式:yoka\u738b (原始:yoka王)function unicode_encode($name){ $name = iconv('utf-8', 'ucs-2', $name); $len = strlen($name); $str = ''; for ($i = 0; $i { $c = $name[$i]; $c2 = $name[$i + 1]; if
Time of Update: 2016-07-25
//讀取檔案內容$fh = fopen($path, "r+");if( flock($fh, lock_ex) ){//加寫鎖 $old_content=json_decode(fread($fh,filesize($path)),true);$old_content=$old_content.$new_content; ftruncate($fh,0); // 將檔案截斷到給定的長度 rewind($fh); // 倒迴文件指標的位置 fwrite($fh,json_encode($old_
Time of Update: 2016-07-25
[mysql]default-character-set=utf8[mysqld]default-character-set=utf8default-storage-engine=myisam在[mysqld]下加入:default-collation=utf8_bininit_connect='set names utf8'複製代碼7、在需要做資料庫操作的php程式前面加上 mb_internal_encoding('utf-8');複製代碼8、create table最後邊加上:
Time of Update: 2016-07-25
header ("content-type: image/png"); $conn = mysql_connect("localhost", "root", ""); //串連資料庫 $colname_rs_article = $_get['id']; //擷取參數idmysql_select_db("cms", $conn); //執行sql $query_rs_article = sprintf("select * from articles where article_id = %s",