Time of Update: 2016-07-25
echo "dev-lang/php fpm" >> /etc/portage/package.useemerge -av dev-lang/php複製代碼配置很簡單,我本機版本是 php5.4,那麼編輯檔案 /etc/php/fpm-php5.4/php-fpm.conf,修改 listen address ;listen = 127.0.0.1:9000listen = /var/run/php-fpm.sock複製代碼nginx開啟 fastcgi USE 標記 echo
Time of Update: 2016-07-25
filelist $dir = 'upload/';if(is_dir($dir)) { if ($dh = opendir($dir)) { while (($file = readdir($dh)) !== false) { if($file!="." && $file!="..") { echo "".$file.""; } }
Time of Update: 2016-07-25
function encode_email($email='test@jbxue.com', $linkText='Contact Us', $attrs ='class="emailencoder"' ){// remplazar aroba y puntos$email = str_replace('@', '@', $email);$email = str_replace('.', '.', $email);$email = str_split($email, 5);$linkText =
Time of Update: 2016-07-25
/* Person.class.php */ class Person { public $name; public $age; function __construct ($name, $age) { $this->name = $name; $this->age = $age; } }
Time of Update: 2016-07-25
/** * Validator for Login. */final class LoginValidator { private function __construct() { } /** * Validate the given username and password. * @param $username and $password to be validated * @return array array of
Time of Update: 2016-07-25
function my_formatSize($size){$size = doubleval($size);$rank =0;$rankchar ='Bytes';while($size>1024){ $size = $size/1024; $rank++;}if($rank==1){ $rankchar="KB";}else if($rank==2){ $rankchar="MB";}else if($rank==3){
Time of Update: 2016-07-25
$a =array(100,80,50,10,0);$b = array("c","f","q","e","z");array_multisort($a,$b);var_dump($a);var_dump($b);?>複製代碼運行結果:array(5) { [0]=> int(0) [1]=> int(10) [2]=> int(50) [3]=> int(80) [4]=> int(100) }array(5) { [0]=> string(1) “z” [1]=> string(1) “e”
Time of Update: 2016-07-25
本文為大家列舉了php新手易犯的幾個小錯誤,供大家參考。1、header already sent 這個錯誤通常會在你使用HEADER的時候出現,他可能是幾種原因本文為大家列舉了php新手易犯的幾個小錯誤,供大家參考。1、header already
Time of Update: 2016-07-25
function get_http_response_code($theURL) { $headers = get_headers($theURL); return substr($headers[0], 9, 3); }?> 複製代碼get_headers的作用就是訪問一個遠程地址,把伺服器發送的HTTP頭以數組形式返回。而$header[0]則是伺服器返回的狀態代碼(如果不出意外的話狀態代碼應該都是第一個返回的)。排除重新導向的例子: /** * Fetches
Time of Update: 2016-07-25
private static $_instance; 複製代碼2)、建構函式和複製函數必須聲明為私人的,防止外部程式new類從而失去單例模式的意義: private function __construct() { $this->_db = pg_connect('xxxx'); } private function __clone() { }//覆蓋__clone()方法,禁止複製 複製代碼(3).
Time of Update: 2016-07-25
class Test { public function __construct(){ $this->_log('start'); } public function __destruct () { $this->_log('finish'); } public function
Time of Update: 2016-07-25
$search = '~^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?~i';$url = 'http://www.php.net/pub/ietf/uri/#Related';$url = trim($url);preg_match_all($search, $url ,$rr);printf("輸出URL資料為:%s\n",var_export( $rr ,TRUE));/*各分組如下 $1 = http:
Time of Update: 2016-07-25
if (ini_get('magic_quotes_gpc')) { function stripslashesRecursive(array $array) { foreach ($array as $k => $v) { if (is_string($v)) { $array[$k] = stripslashes($v);
Time of Update: 2016-07-25
//php當前迴圈為1,迴圈由裡到外依次遞增,break預設為1,例如跳出第2層迴圈for ($i=0;$i foreach (array(1,2,3) as $val){ foreach (array(1,2,3) as $val){ echo "1層迴圈"; break 2; //跳出第2層迴圈 } echo "2層迴圈"; }
Time of Update: 2016-07-25
/** * 操縱檔案類 * * 例子: * FileUtil::createDir('a/1/2/3'); 測試建立檔案夾 建一個a/1/2/3檔案夾 * FileUtil::createFile('b/1/2/3'); 測試建立檔案 在b/1/2/檔案夾下面建一個3檔案 * FileUtil::createFile('b/1/2/3.exe'); 測試建立檔案
Time of Update: 2016-07-25
$arr = array( "0" => array(line_num => "10", occur_time => "2007-11-19 10:25:04+08"), "1" => array(line_num => "9", occur_time => "2007-11-19 10:25:04+08"), "2" => array(line_num => "25", occur_time => "
Time of Update: 2016-07-25
//1.定義一些方法,子類必須完全實現這個抽象中所有的方法//2.不能從抽象類別建立對象,它的意義在於被擴充//3.抽象類別通常具有抽象方法,方法中沒有大括弧//4.抽象方法不必實現具體的功能,由子類來完成//5.在子類實現抽象類別的方法時,其子類的可見度必須大於或等於抽象方法的定義//6.抽象類別的方法可以有參數,也可以為空白//7.如果抽象方法有參數,那麼子類的實現也必須有相同的參數個數//////////////////////////////介面類的定義:interface Shop{
Time of Update: 2016-07-25
//do somethingsleep(3);//do something$running_time = time() - $_SERVER['REQUEST_TIME'];echo '頁面已耗用時間:',$running_time,' 秒';?>複製代碼執行例子輸出如下:頁面已耗用時間:3 秒註解:$_SERVER['REQUEST_TIME'] 是 PHP 內建的當前頁面開始運行時的時間戳記,在當前頁面運行結束時將 time() - $_SERVER['REQUEST_TIME']
Time of Update: 2016-07-25
class Person{//下面是人的成員屬性var $name; //人的名子var $***; //人的性別var $age; //人的年齡//下面是人的成員方法function say() //這個人可以說話的方法{echo "這個人在說話";}function run() //這個人可以走路的方法{echo "這個人在走路";}}?> 複製代碼3.5.如何執行個體化對象上面說過php
Time of Update: 2016-07-25
class runTime { var $StartTime = 0; var $StopTime = 0; var $TimeSpent = 0; function start(){ $this->StartTime = microtime(); } function stop(){ $this->StopTime = microtime(); } function spent() { if