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
//在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
IT教程分享~!PHP/Linux/html/JS/手遊開發/MySQL/等教程~!廢話不說,上資源:新版Linux視頻教程:http://pan.baidu.com/s/1c01r15Yhtml5視頻教程:http://yun.baidu.com/s/1jGIJLumJava、Android視頻教程:http://yun.baidu.com/s/1dDvOH37cocos2d-x視頻教程:http://yun.baidu.com/s/1pJlZu4NJavaScript視頻教程:http://
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編程中,有關物件導向中有個函數稱為建構函式,是對象被建立時自動調用的方法,用來完成類初始化的工作。因為只要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 __destruct(){ /* class initialization code */} 複製代碼解構函式是由系統自動調用,不能帶參數。例子: class des{function __destruct(){ echo "運行結束,執行解構函式";} } $p=new des(); /* 執行個體化類 */ $sum=0; for($i=0;$i$sum=$sum+$i;echo $sum ."";}?> 複製代碼
Time of Update: 2016-07-25
class person{ public function __destruct() { echo "解構函式在這裡執行"; echo "這裡一般用來放置,關閉資料庫,關閉檔案等等收尾工作。"; } } $p = new person(); for ($i = 0; $i echo " $i"; } //在php程式結束前,對象被銷毀了。 ?>
Time of Update: 2016-07-25
class counter { private static $count = 0; function __construct() { self::$count++; } function __destruct() { self::$count--; } function getcount() {
Time of Update: 2016-07-25
header("content-type: text/html; charset=utf-8");複製代碼php頁面為gbk編碼 header("content-type: text/html; charset=gb2312");複製代碼php頁面為big5編碼 header("content-type: text/html; charset=big5");複製代碼通常情況以上代碼放在php頁面的首頁。用header或meta實現php頁面編碼的區別一、頁面編碼1. 使用
Time of Update: 2016-07-25
/* * 遍曆目錄 * fopen() * fread() * fclose() * @opendir(目標路徑);E_WARNINE * readdir(目錄引用控制代碼) rewinddir() * closedir() * * 在程式設計中,控制代碼是一種特殊的智能指標 。當一個應用程式要引用其他系統(如資料庫、作業系統) * 所管理的記憶體塊或對象時,就要使用控制代碼。控制代碼與普通指標的區別在於, * 指標包含的是引用對象的記憶體位址,而控制代碼則是由系統所管理的引用標識, *
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
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
$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
//將內容進行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",