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
//php漢字轉碼class qswhBig5{ var $qswhData; function qswhBig5($filename="qswhBig5.php"){ $this->qswhData=file($filename); } function qswhStr($gb,$fail="??"){ /******(qiushuiwuhen 2002-9-6)******/ $ret=""; for($i=0;$i if(($p=ord(substr($gb,$i,1)))>1
Time of Update: 2016-07-25
本文分享了php socket函數庫中常用函數,有研究php socket編程的朋友,可以參考學習下。php socket函數庫: 函數名 描述socket_accept() 接受一個Socket串連socket_bind() 把socket綁定在一個IP地址和連接埠上socket_clear_error() 清除socket的錯誤或最後的錯誤碼socket_close() 關閉一個socket資源socket_connect()
Time of Update: 2016-07-25
為大家解答php是什麼檔案,php檔案怎麼開啟,php是英文超級文本預先處理語言Hypertext Preprocessor的縮寫,它是一種html內嵌式的語言。對於網頁開發人員來說php是什麼檔案和php檔案怎麼開啟的問題再簡單不過了,因為他們每天都跟php檔案打交道。那這個php是什麼檔案呢?指令碼學堂小編為大家做下介紹。php是什麼檔案php是英文超級文本預先處理語言Hypertext
Time of Update: 2016-07-25
$var = '';// 結果為 true,所以後邊的文本將被列印出來。if (isset($var)) { print "this var is set set so i will print.";}// 在後邊的例子中,我們將使用 var_dump 輸出 isset() 的傳回值。$a = "test";$b = "anothertest";var_dump( isset($a) ); // truevar_dump( isset ($a, $b) ); //
Time of Update: 2016-07-25
/** * $str 原始字串 * $encoding 原始字串的編碼,預設GBK * $prefix 編碼後的首碼,預設"" * $postfix 編碼後的尾碼,預設";" */function unicode_encode($str, $encoding = 'GBK', $prefix = '', $postfix = ';') { $str = iconv($encoding, 'UCS-2', $str); $arrstr = str_split($str, 2);
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
strrev($str){ $len=strlen($str); $newstr = ''; for($i=$len;$i>=0;$i--) { $newstr .= $str{$i}; } return $newstr;} 複製代碼15.實現中文字串截取無亂碼的方法。答:mb_substr()16.使用php寫一段簡單查詢,查出所有姓名為“張三”的內容並列印出來 表名username tel
Time of Update: 2016-07-25
本文介紹了php中漢字編碼轉換的一些知識,分析了php編碼轉換的原理與方法,有需要的朋友參考下。有關對mysql4.1字元集的理解,再講述如何php如何適應mysql的這種變化。同樣適用於mysql5及以上的版本。一.原理篇mysql的字元集裡有兩個概念,一個是“character set(字元集)”,另一個是“collations”。1. collationscollations翻成中文是“校正”,在網頁開發的過程中,這個詞彙,只在mysql裡使用,主要作用是指導mysql對字元的比較,比如,
Time of Update: 2016-07-25
$string=mb_convert_encoding($string, 字元輸出編碼, 原字元編碼); 複製代碼例如:網頁使用gbk編碼,字串使用utf-8編碼,將字元轉換為網頁顯示編碼。 echo mb_convert_encoding("php編碼轉換", "gbk",
Time of Update: 2016-07-25
$a = date("y-m-d h:i:s", strtotime("-1 day"));print_r($a);複製代碼2、echo(),print(),print_r()的區別(3分) echo 和print不是一個函數,是一個語言結構int print(string $arg), 只有一個參數echo arg1,arg2; 可以輸出多個參數,返回voidecho和print只能列印出string,不能列印出結構print_r能列印出結構比如 $arr =
Time of Update: 2016-07-25
/** * @ string 需要轉換的文字 * @ encoding 目標編碼 **/ function detect_encoding($string,$encoding = 'gbk'){ $is_utf8 = preg_match('%^(?:[\x09\x0a\x0d\x20-\x7e]| [\xc2-\xdf][\x80-\xbf]| \xe0[\xa0-\xbf][\x80-\xbf] |
Time of Update: 2016-07-25
$img = file_get_contents('http://www.baidu.com/img/baidu_logo.gif'); file_put_contents('1.gif',$img); echo ''; ?>複製代碼3、 function is_gfriend($na,$nb){ $random1=rand(1,5);//計算他們有1/5的緣分$random2=rand(1,5);if ($random1==$random2)return
Time of Update: 2016-07-25
/*** 添加背景* @param string $src 圖片路徑* @param int $w 背景映像寬度* @param int $h 背景映像高度* @return 返回加上背景的圖片* **/public function addBg($src,$w,$h){$bg = imagecreatetruecolor($w,$h);$white =
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
header("content-type: text/html; charset=utf-8");echo mb_convert_encoding("妳係我的友仔", "utf-8", "gbk");?> 複製代碼gb2312 to big5編碼轉換: header("content-type: text/html; charset=big5");echo mb_convert_encoding("你是我的朋友", "big5", "gb2312");?>
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
require_once('pinyin_table.php'); function get_pinyin_array($string){ global $pinyin_table; $flow = array(); for ($i=0;$i { if (ord($string[$i]) >= 0x81 and ord($string[$i]) { $h = ord($string[$i]);
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",