Time of Update: 2016-07-25
echo '';複製代碼2、在php頁面或html頁面 複製代碼二,使用header函數 在控制器或頁面中: header("content-type:text/html;
Time of Update: 2016-07-25
$t=time(); echo date("Y-m-d H:i:s",$t);複製代碼第一個參數的格式分別表示: a - "am" 或是 "pm" A - "AM" 或是 "PM" d - 幾日,二位元字,若不足二位則前面補零; 如: "01" 至 "31" D - 星期幾,三個英文字母; 如: "Fri" F - 月份,英文全名; 如: "January" h - 12 小時制的小時; 如: "01" 至 "12" H - 24 小時制的小時; 如: "00" 至 "23" g
Time of Update: 2016-07-25
/** 返迴文件從X行到Y行的內容(支援php5、php4) * @param string $filename 檔案名稱 * @param int $startLine 開始的行數 * @param int $endLine 結束的行數 * @return string */function getFileLines($filename, $startLine = 1, $endLine=50, $method='rb') { $content = array();
Time of Update: 2016-07-25
if (isset($url)){Header("HTTP/1.1 303 See Other");Header("Location: $url");exit; //from bbs.it-home.org}?> 複製代碼注意,"Localtion:"後面有一個空格。二、用HTML標記用HTML標記,就是用META的REFRESH標記。舉例: >複製代碼三、用指令碼舉例如下: $url="http://bbs.it-home.org";echo "";echo "location.href="/
Time of Update: 2016-07-25
header("content-type:text/html;charset=utf-8"); //資料庫連接 $conn = mysql_connect("localhost", "root", "111") or die("not connnected : ".mysql_error()); mysql_select_db("test", $conn); mysql_query("set names utf8"); //查詢共有多少行資料 $sql1 =
Time of Update: 2016-07-25
$mail = new PHPMailer();$mail->Charset='UTF-8′;複製代碼相信有不少朋友是設定成”GBK”或“GB2312”的,我開始也是,後來瞭解到Mail是國際化的,如果想在像Gmail等那樣的國際化郵箱正確顯示中文,請將編碼設定為“UTF-8”;3,設定標題編碼;如果您測試過多種郵箱,會發現標題中文是亂碼的,沒錯,即使您設定了 $mail->Charset=”UTF-8″;既然學習php應該多看看php手冊或留意php.net
Time of Update: 2016-07-25
分享下PHP中ini_set和ini_get函數的用法進,學習php編程的朋友可以關注下。php中的ini_set函數是php內建的用來修改設定php.ini設定檔的函數,用這個函數很方便,不用去手動修改php.ini檔案。有時也沒有許可權去修改php.ini檔案,就可以使用這個函數。文法:ini_set("選項","值");該函數用時最好放到php的指令碼最頭部比如:ini_set("max_execution_time",
Time of Update: 2016-07-25
curl_setopt($this->mSh, CURLOPT_HTTPPROXYTUNNEL, true);curl_setopt($this->mSh, CURLOPT_PROXY, $phost);複製代碼php文檔中沒有詳細說明,不過man curl中有詳細解釋,兩者都是代理,proxytunnel(-p參數)允許其他協議通過http代理傳輸,而proxy(-x參數)則只能走http協議。所以我猜測,google baidu的伺服器和curl的proxytunnel不和,所以返回403。
Time of Update: 2016-07-25
print_r(iconv_get_encoding("all"));複製代碼2,對指字串進行編碼轉換: echo
Time of Update: 2016-07-25
/** * desription 壓縮圖片 * @param sting $imgsrc 圖片路徑 * @param string $imgdst 壓縮後儲存路徑 */function image_png_size_add($imgsrc,$imgdst){ list($width,$height,$type)=getimagesize($imgsrc); $new_width = ($width>600?600:$width)*0.9; $new_height =($height>
Time of Update: 2016-07-25
本文介紹了PHP5.3與5.5中一些廢棄與到期的函數,大家在使用php函數時注意下,感興趣的朋友做個參考。從PHP5.3開始加入了一個新的報錯層級DEPRECATED,即將廢棄/到期。在php5.3被放棄的函數有: call_user_method() //使用 call_user_func() 替代call_user_method_array() //使用 call_user_func_array() 替代define_syslog_variables()dl()ereg() //使用
Time of Update: 2016-07-25
{$變數名稱}例子:{$username} //普通變數{$userinfo["email"]} //數組方式{$userinfo["sub"]["name"]} //三維數組方式{$userinfo:email} //對象方式{$userinfo.email}...複製代碼普通輸出輸出模板中的變數,格式如下:{$變數名稱}例子: {$username} //普通變數{$userinfo["email"]} //數組方式{$userinfo["sub"]["name"]}
Time of Update: 2016-07-25
$i = imagecreatefromjpeg("image.jpg"); for ($x=0;$xfor ($y=0;$y$rgb = imagecolorat($i,$x,$y); $r = ($rgb >> 16) & 0xFF; $g = ($rgb >> & 0xFF; $b = $rgb & 0xFF; $rTotal += $r; $gTotal += $g; $bTotal += $b; $total++;
Time of Update: 2016-07-25
本文介紹了lnmp架構下php安全配置的方法,包括禁用不安全PHP函數、關閉php錯誤記錄檔、php上傳分離、關閉php資訊、禁止動態載入連結庫、禁用開啟遠程url等安全措施。php安全配置的幾個方面:1、使用open_basedir限制虛擬機器主機跨目錄訪問
Time of Update: 2016-07-25
本文介紹了php匯出excel儲存格自動換行的實現方法,Spreadsheet Excel Writer可以將資料匯出成Excel檔案,並設定字型、顏色、儲存格大小等格式,需要的朋友參考下。Spreadsheet Excel Writer可以將資料匯出成Excel檔案,並設定字型、顏色、儲存格大小等格式。$workbook = new Spreadsheet_Excel_Writer(); $filename = date('YmdHis').'.xls';//csv $workbook->
Time of Update: 2016-07-25
// 建立資料庫連接$link = mysql_connect("localhost", "mysql_user", "mysql_passWord") or die("Could not connect: " . mysql_error()); // 擷取當前頁數if( isset($_GET['page']) ){ $page = intval( $_GET['page'] );}else{ $page = 1;} // 每頁數量$PageSize = 10; //
Time of Update: 2016-07-25
/** 預設首頁 **/ class DefaultController extends AppController { public function index() { $len = 5; $str = "ABCDEFGHIJKLNMPQRSTUVWXYZ123456789";$im = imagecreatetruecolor ( 70, 20 ); $bgc = imagecolorallocate($im, 255, 255, 255); $bgtxt =
Time of Update: 2016-07-25
/*author:默默date :2006-12-03*/$page=isset($_get['page'])?intval($_get['page']):1; //這句就是擷取page=18中的page的值,假如不存在page,那麼頁數就是1。$num=10; //每頁顯示10條資料$db=mysql_connect("host","name","pass"); //建立資料庫連接$select=mysql_select_db("db",$db);
Time of Update: 2016-07-25
session_start();//隨機產生驗證碼的字串function random($len) { $srcstr="ABCDEFGHIJKLMNPQRSTUVWXYZ123456789"; mt_srand(); $strs=""; for($i=0;$i $strs.=$srcstr[mt_rand(0,33)]; } return ($strs);}$str=random(5); //隨機產生的字串$width=60; //驗證碼圖片的寬度$height=25;
Time of Update: 2016-07-25
php數組的定義與數組遍曆,php數組函數的用法與例子,php數組取值賦值,php多維陣列的迴圈輸出等,供大家學習參考。1、php數組定義和遍曆 2、php數組函數1、數組定義: $arr=array(1,2,3);//索引數組,下標全是數字$arr=array("name"=>"user1","age"=>"30");//關聯陣列,下標中包含字母//下標只有兩種,要麼是字母,要是是不帶雙引號的數字1,3,"age"=>4,5,100=>6,7,400=>8,9); echo "";