Time of Update: 2017-01-13
windows系統下mail函數需要配置1.從http://glob.com.au/sendmail/下載sendmail.zip 2.解壓到C:下,例如C:\php\sendmail,最好短路徑,長路徑名有可能產生問題。 3.修改php.ini如下 sendmail_path = "C:\wamp\sendmail\sendmail.exe -t" 4.根據你自己的配置環境修改sendmail.ini。
Time of Update: 2017-01-13
用法nlink() 函數刪除檔案。若成功,則返回 true,失敗則返回 false。文法unlink(filename,context)樣本: 代碼如下複製代碼 $tmpdata = $this->_agency_mod->find ( intval ( $value ) );$img = $tmpdata [$value] ['agency_image'];if(!empty($img)){ $img = '../data/agency/' .
Time of Update: 2017-01-13
在PHP代碼中調用date函數時,在日誌裡看到如下報錯PHP Warning: date(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods
Time of Update: 2017-01-13
PHP CLI(命令列模式下)接受參數有多種方法:(1)使用$argv接受參數<?php 代碼如下複製代碼 //變數僅在 register_argc_argv 開啟時可用。print_r($argc); //CLI下擷取參數的數目,最小值為1print_r($argv); //CLI下傳遞給指令碼的參數數組,第一個參數總是當前指令碼的檔案名稱,因此 $argv[0] 就是指令檔名。 結果: PHP
Time of Update: 2017-01-13
在用PHP5.3以上的PHP版本時,只要是涉及時間的會報一個“PHP Warning: date() [function.date]: It is not safe to rely on the system’s timezone settings.You are *required* to use the date.timezone setting or the date_default_timezone_set() function.In case you used
Time of Update: 2017-01-13
call_user_func() 函數類似於一種特別的調用函數的方法,使用方法如下: 代碼如下複製代碼 function test($a, $b) { echo $a*$b;}call_user_func('test', 4, 5);//---- echo 20 ----//
Time of Update: 2017-01-13
在通過php的header('Location:http://www.111cn.net')做跳轉時.有時會不成功.追其原因有以下幾種情況:寫法錯誤•location和“:”號間不能有空格,否則會出錯。•在用header()前不能有任何的輸出。•header後的PHP代碼還會被執行,所以在函數之前最好加上exit()來停止之後程式的執行另外還有一個問題,算是比較低級了編碼報錯 代碼如下複製代碼 <?php
Time of Update: 2017-01-13
PHP函數 sprintf() 函數官方定義為:sprintf() :把格式式的字串寫入一個變數中文法為:sprintf(format,arg1,arg2,arg++);參數:format:必須,轉換格式arg1 :必須,規定插入 format 字串中第一個%符號處的參數arg1 :可選,規定插入 format 字串中第二個%符號處的參數arg1++:可選,規定插入 format 字串中第三、四等%符號處的參數參數 format
Time of Update: 2017-01-13
例子XML 檔案: 代碼如下 複製代碼 <?xml version="1.0" encoding="ISO-8859-1"?> <note> <to>George</to>
Time of Update: 2017-01-13
比如縮排關係,每次寫還要在前面加上echo "<pre>" ,其實這很不爽的!還有內部的var_dump(),反正效果不怎麼理想的,所以就自己寫了這個,在設定檔中加上此函數、每次調用只要dump($var) $var不管是變數、數組、類庫都能列印出來——爽呀! 代碼如下複製代碼 /** * 輸出變數的內容,通常用於調試 * @package Core * @param
Time of Update: 2017-01-13
str_pad() 函數把字串填充為指定的長度。文法str_pad(string,length,pad_string,pad_type) 參數 描述 string 必需。規定要填充的字串。 length 必需。規定新字串的長度。如果該值小於原始字串的長度,則不進行任何操作。
Time of Update: 2017-01-13
Nginx+PHP-CGI(php-fpm) 的Web環境突然發現系統負載上升,top 查看後發現很多 php-cgi 進程 CPU 使用率接近100%找其中一個 CPU 100% 的 php-cgi 進程的 PID,用strace -p 10747跟蹤,結果發現以下結果:select(7, [6], [6], [], {15, 0}) = 1 (out [6], left {15, 0})poll([{fd=6, events=POLLIN}], 1, 0) = 0
Time of Update: 2017-01-13
header分為三部分:第一部分為HTTP協議的版本(HTTP-Version);第二部分為狀態碼(Status);第三部分為原因短語(Reason-Phrase)。header()函數使用說明: 一、作用: ~~~~~~~~~
Time of Update: 2017-01-13
php閉包函數比如你現在就可以這樣使用: 代碼如下複製代碼 $closure = function($param) { echo $param; }; 感覺和js是不是一樣的用法了.一些閉包函數執行個體 代碼如下複製代碼 function test(){$test='';$test=function ($str){echo 'test';return $str;};timeout('Y-m-d H:i:s',function
Time of Update: 2017-01-13
isset函數是檢測變數是否設定。格式:bool isset ( mixed var [, mixed var [, ...]] )傳回值:若變數不存在則返回 FALSE 若變數存在且其值為NULL,也返回 FALSE 若變數存在且值不為NULL,則返回 TURE 同時檢查多個變數時,每個單項都符合上一條要求時才返回 TRUE,否則結果為 FALSE如果已經使用 unset() 釋放了一個變數之後,它將不再是 isset()。若使用 isset() 測試一個被設定成 NULL 的變數,將返回
Time of Update: 2017-01-13
str_split() 可以將字串按照需要的長度做分割, 但是如果字串中有UTF-8編碼的中文出現,就會出現亂碼。如果需要實現支援中文的按照長度分割字串的功能就需要額外處理 代碼如下複製代碼 <?php $str = 'hello world'; $arr = str_split($str); print_r($arr); /* Array ( [0] => h [1] => e &
Time of Update: 2017-01-13
我們在程式中可能經常看到這麼一個函數 代碼如下複製代碼 function setErrorReporting(){ //從設定檔讀取當前是否為開發環境 if (DEV_ENV == true) { ini_set("error_reprorting", "E_ALL &
Time of Update: 2017-01-13
代碼如下複製代碼 $img = imagecreate(180,50); $ip = $_server['remote_addr']; imagecolortransparent($img,$bgcolor); $bgcolor = imagecolorallocate($img, 0x2c,0x6d,0xaf); // 背景顏色 $shadow = imagecolorallocate($img, 250,0,0); // 陰影顏色 $textcolor =
Time of Update: 2017-01-13
代碼如下複製代碼 class resizeimage{ //圖片類型 var $type; //實際寬度 var $width; //實際高度 var $height; //改變後的寬度 var $resize_width; //改變後的高度
Time of Update: 2017-01-13
代碼如下複製代碼 $directory = 'gallery';$allowed_types=array('jpg','jpeg','gif','png');$file_parts=array();$ext='';$title='';$i=0;$dir_handle = @opendir($directory) or die("there is an error with your image directory!");while ($file =