Time of Update: 2016-07-25
$a='11'; $b=11; if($a===$b) { echo '嚴格相等'; } else if($a==$b) { echo '相等'; } else { echo '不等'; } 複製代碼 運行結果為相等。下面說一下刪除數組中的元素的方法:舉例如下: $_POST=array("firstname"=>'f',"lastname"=>'j',"email"=>"fj@qq.com","password"=>"123",'rpassword'
Time of Update: 2016-07-25
// 求和 function rsum($v, $w) { return $v; } // 求沉積 function rmul($v, $w) { return $v; } $a = array(1, 2, 3, 4, 5); $x = array(); $b = array_reduce($a, "rsum"); echo '
Time of Update: 2016-07-25
foreach (getallheaders() as $name => $value) { echo "$name: $value\n"; } ?> 複製代碼不過這個函數只能在apache環境下使用,iis或者nginx並不支援,可以通過自訂函數實現。 if (!function_exists('getallheaders')) { function getallheaders() {
Time of Update: 2016-07-25
/*只支援整數的小寫金額轉中文大寫*/class ChineseNumber{//var $basical=array(0=>"零","一","二","三","四","五","六","七","八","九");var $basical=array(0=>"零","壹","貳","三","肆","伍","陸","柒","捌","玖");//var $advanced=array(1=>"十","百","千");var $advanced=array(1=>"拾","佰","仟")
Time of Update: 2016-07-25
/** 控制器: @link jbxue.com*/class DemoController { function index() { echo('hello world'); } } /* End of file democontroller.php */複製代碼以上檔案只是建立了一個名為DemoController的對象並包含一個index的方法,該方法輸出hello world。下面在index.php中執行DemoController中index方法。 檔案:index.php
Time of Update: 2016-07-25
/**功能:檢測並清除BOMlink:bbs.it-home.org*/ if(isset($_GET['dir'])){ $basedir=$_GET['dir']; }else{ $basedir = '.'; } $auto = 1; checkdir($basedir);function checkdir($basedir){ if($dh = opendir($basedir)){ while(($file = readdir($dh)) !== false){
Time of Update: 2016-07-25
RewriteEngine On RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule (.+) index.php/$1 [L] 複製代碼
Time of Update: 2016-07-25
{some_text} {some_more_text}複製代碼它們在文檔中沒有意義,它們代表的意義只是PHP將用其他的東西來替換它。如果你同意這種對視圖的鬆散描述,你也就會同意絕大多數模板方案並沒有有效分離視圖和模型。模板標籤將被替換成什麼存放在模型中。在你實現視圖時問自己幾個問題:“全體視圖的替換容易嗎?”“實現一個新視圖要多久?” “能很容易的替換視圖的描述語言嗎?(比如在同一個視圖中用SOAP文檔替換HTML文檔)”二、模型(Model)
Time of Update: 2016-07-25
/**php時間戳記綜合應用的例子date: 2013/2/19link: http://bbs.it-home.org*/$t = time(); $t1 = mktime(0,0,0,date(“m”,$t),date(“d”,$t),date(“Y”,$t)); $t2 = mktime(0,0,0,date(“m”,$t),1,date(“Y”,$t)); $t3 = mktime(0,0,0,date(“m”,$t)-1,1,date(“Y”,$t)); $t4 = mktime(0,
Time of Update: 2016-07-25
function server_transfer($dest){global ...; // 把希望在新頁面中用到的本頁變數或自訂的全域變數列在這裡include $dest; // 運行新指令碼exit; // 退出本指令碼}?> 複製代碼注意:1)、如果跳轉之前輸出的任何資料都會在新頁面中顯示,除非使用 ob_start 緩衝,可以在跳轉之前清空,這樣就互不影響了。2)、由於新頁面在一個自訂的函數範圍內運行,所以本頁面定義的變數不會影響到新頁面,這點是好處也是壞處。3)、新頁面依然可以用 $
Time of Update: 2016-07-25
function getWeekName($data,$format = '星期') { $week = date( "D ",$data); switch($week) { case "Mon ": $current = $format."一"; break;
Time of Update: 2016-07-25
$file = fopen("contacts.csv","r"); print_r(fgetcsv($file)); fclose($file); ?>複製代碼CSV 檔案: George, John, Thomas, USA James, Adrew, Martin, USA 輸出類似: Array ( [0] => George [1] => John [2] => Thomas [3] => USA )例2: $file = fopen("contacts.csv","r"
Time of Update: 2016-07-25
function ip_test($ip,$iprule){ $ipruleregexp=str_replace('.*','ph',$iprule); $ipruleregexp=preg_quote($ipruleregexp,'/'); $ipruleregexp=str_replace('ph','\.[0-9]{1,3}',$ipruleregexp); if(preg_match('/^'.$ipruleregexp.'$/',$ip))
Time of Update: 2016-07-25
DHTML技術各項功能的實現都依賴於使用用戶端指令碼與瀏覽器宿主及在宿主中輸出的Web頁面之間的互動,這種互動是通過對象這個技術手段實現的。DHTML技術各項功能的實現都依賴於使用用戶端指令碼與瀏覽器宿主及在宿主中輸出的Web頁面之間的互動,這種互動是通過對象這個技術手段實現的。BOM與DOM的區別 # DHTML技術各項功能的實現都依賴於使用用戶端指令碼與瀏覽器宿主及在宿主中輸出的Web頁面之間的互動,這種互動是通過對象這個技術手段實現的。# BOM即Browser Object
Time of Update: 2016-07-25
$arr1 = $dblink->mem_fetch_array ( "SELECT t_pid,imgname,invented,score FROM `t_sum_giftimg` where t_pid=3 or t_pid=6", 0 ); $arr2 = $dblink->mem_fetch_array ( "SELECT t_pid,imgname,invented,score FROM `t_sum_giftimg` where t_pid=10 or t_pid=12", 0
Time of Update: 2016-07-25
/* trim 去除一個字串兩端空格, rtrim 是去除一個字串右部空格, ltrim 是去除一個字串左部空格。 */ echo trim(" 空格 ").""; echo rtrim(" 空格 ").""; echo ltrim(" 空格 ").""; ?>複製代碼方法2:通過Regex替換,功能更強。php去除字串首尾空格(包括全形) $str=" 指令碼學堂 bbs.it-home.org "; $str = mb_ereg_replace('^( | )+', '',
Time of Update: 2016-07-25
/*-------------------------------------------------------** Copyright (c) 2011 Baidu.com, Inc. All Rights Reserved* $Id$**-------------------------------------------------------*///時間戳記轉日期$date_time_array = getdate(1297845628); //1311177600 13168655
Time of Update: 2016-07-25
function unhtml($content){ $content=htmlspecialchars($content); $content=str_replace(chr(13),"",$content); $content=str_replace(chr(32),"",$content); $content=str_replace("[_[","$content=str_relace(")_)",">",$content); $content=str_replace("|_|","",$
Time of Update: 2016-07-25
function getWeekDate($year,$weeknum){ $firstdayofyear=mktime(0,0,0,1,1,$year); $firstweekday=date('N',$firstdayofyear); $firstweenum=date('W',$firstdayofyear); if($firstweenum==1){ $day=(1-($firstweekday-1))+7*($weeknum-1);
Time of Update: 2016-07-25
function_exists(date_default_timezone_set);//在這他總是返回1,這函數是判斷這裡面的字元是不是一個定義了的函數名 date_default_timezone_set("Etc/GMT");//這是格林威治標準時間,得到的時間和預設時區是一樣的 date_default_timezone_set("Etc/GMT+8");//這裡比林威治標準時間慢8小時