Time of Update: 2017-01-13
我們先要明白中文雙位元組字元編碼範圍1. GBK (GB2312/GB18030)x00-xff GBK雙位元組編碼範圍x20-x7f ASCIIxa1-xff 中文 gb2312x80-xff 中文 gbk2. UTF-8 (Unicode)u4e00-u9fa5 (中文)x3130-x318F (韓文xAC00-xD7A3 (韓文)u0800-u4e00 (日文)擷取指定的中文與字元例1 代碼如下複製代碼 <?php$str = '正則如何匹配中文字在某中文字串中?
Time of Update: 2017-01-13
兩種方法簡單說明如下:一, 利用PHP的輸出控制函數(Output Control)得到靜態頁面字串,再寫入到新的檔案中。使用說明:1、執行個體化 代碼如下複製代碼 $cache = new Cache();2、設定緩衝時間和緩衝目錄$cache = new Cache(60, '/any_other_path/'); 第一個參數是緩衝秒數,第二個參數是緩衝路徑,根據需要配置。預設情況下,緩衝時間是 3600 秒,緩衝目錄是 cache/3、讀取緩衝
Time of Update: 2017-01-13
上傳圖片form提交target到一個隱藏的iframe裡, 代碼如下複製代碼 form action="upload.php" id="form1" name="form1" enctype="multipart/form-data" method="post" target="uploadIframe"> <!--上傳圖片頁面 -
Time of Update: 2017-01-13
擷取IP地址 代碼如下複製代碼 <?phpfunction GetIP() { if ($_SERVER["HTTP_X_FORWARDED_FOR"]) $ip = $_SERVER["HTTP_X_FORWARDED_FOR"]; else if
Time of Update: 2017-01-13
一般來說,總是把類的屬性定義為private,這更符合現實的邏輯。但是,對屬性的讀取和賦值操作是非常頻繁的,因此在PHP5中,預定義了兩個函數“__get()”和“__set()”來擷取和賦值其屬性,以及檢查屬性的“__isset()”和刪除屬性的方法“__unset()”。上一節中,我們為每個屬性做了設定和擷取的方法,在PHP5中給我們提供了專門為屬性設定值和擷取值的方法,“
Time of Update: 2017-01-13
1、設定Cookie1. PHP 的COOKIE cookie 是一種在遠程瀏覽器端儲存資料並以此來跟蹤和識別使用者的機制。 PHP 在http 協議的頭資訊裡發送cookie,因此 setcookie() 函數必須在其它資訊被輸出到瀏覽器 前調用,這和對 header() 函數的限制類似。1.1 設定cookie:
Time of Update: 2017-01-13
一、讓PHP定時運行吧!1、 編輯如下代碼,並儲存為test.php: 代碼如下複製代碼 <?php$fp = @fopen("test.txt", "a+");fwrite($fp, date("Y-m-d H:i:s") . " 讓PHP定時運行吧!n");fclose($fp);?> 開啟文本輸入:D:php4php.exe -q
Time of Update: 2017-01-13
可以使用使用json_last_error()函數擷取到的傳回值來協助我們判斷出問題的原因。其中如果提示錯誤JSON_ERROR_SYNTAX(Syntax error),表示json串格式錯誤。可以通過以下幾個方式排錯:1. json字串必須以雙引號包含 代碼如下複製代碼 $output = str_replace("'", '"', $output);2. json字串必須是utf8編碼$output = iconv('gbk', 'utf8
Time of Update: 2017-01-13
在運行phpinfo時碰到提示如下PHP Warning: phpinfo() has been disabled for security reasons in XX.php on line XX這段話的意思是告訴我們由於安全考慮 phpinfo() 函數被禁用, 如果你有伺服器系統管理權限請修改 php.ini 設定檔參數並重啟apache 重新啟用.開啟php安裝路徑開啟php.ini檔案具體執行個體在php.ini中存在
Time of Update: 2017-01-13
根據網上有朋友介紹說原因可能是伺服器開了GZIP壓縮。下面是用firebug查看我的部落格的頭資訊,Gzip是開了的。要求標頭資訊原始頭資訊 代碼如下複製代碼 Accept text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8Accept-Encoding gzip, deflateAccept-Language zh-cn,zh;q=0.8,en-us;q=0.5,en;
Time of Update: 2017-01-13
三種取得副檔名php教程代碼 代碼如下複製代碼 <?php //方法一: function extend_1($file_name) { $retval=""; $pt=strrpos($file_name, "."); if ($pt)
Time of Update: 2017-01-13
代碼如下複製代碼 //為了避免重複包含檔案而造成錯誤,加了判斷函數是否存在的條件:$page =
Time of Update: 2017-01-13
代碼如下複製代碼 <?php header("content-type:application/vnd.ms-excel; charset=gbk");
Time of Update: 2017-01-13
代碼如下複製代碼 if(file_exists("data.txt")) { print("這個檔案存在"); //檔案存在 print(fileinode("data.txt")); } else { print("檔案不存在"); //檔案不存在 } 方法二
Time of Update: 2017-01-13
代碼如下複製代碼 session_start();/* get post */ if (!function_exists("getpost")){function getpost(){if(count($_post)){foreach($_post as $key => $value){global ${$key};${$key}=$value;}}}}/* get get */ if
Time of Update: 2017-01-13
代碼如下複製代碼 <tr> <td align="center" bgcolor="#f6f6f6">新聞標題:</td> <td height="25" colspan="2" align="left" bgcolor="#f6f6f6" style="width:
Time of Update: 2017-01-13
代碼如下複製代碼 <?php// 說明:擷取無參數urlfunction curpageurl() { $pageurl = 'http'; if ($_server["https教程"] == "on") { $pageurl .=
Time of Update: 2017-01-13
方法一 代碼如下複製代碼 function generate_password( $length = 8 ) { // 密碼字元集,可任意添加你需要的字元 $chars = 'abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*()-_ []{}<>~`+=,.;:/?|';
Time of Update: 2017-01-13
代碼如下複製代碼 // 串連資料庫$conn = mysql_connect("localhost", "phpdb", "phpdb");mysql_select_db("test",$conn);?><?// 取得網頁的參數$id=$_post['id'];// 判斷該使用者名稱是否已經存在$checksql="select * from image where id='$
Time of Update: 2017-01-13
代碼如下複製代碼 <!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"><html xmlns="http://www.111cn.net/1999/xhtml"><head><meta