Time of Update: 2016-07-25
function safeEncoding($string,$outEncoding ='UTF-8') { $encoding = "UTF-8"; for($i=0;$i { if(ord($string{$i}) continue; if((ord($string{$i})&224)==224) {
Time of Update: 2016-07-25
/** php日曆功能* edit: bbs.it-home.org*/@date_default_timezone_set('RPC');function show_calender(){ $starttime=microtime(); //處理請求日期 $y= isset($_GET["y"]) ? intval($_GET["y"]) : date("Y"); $m= isset($_GET["m"]) ? intval($_GET["m"]) : date("m");
Time of Update: 2016-07-25
//檢測網路是否串連function varify_url($url){ $check = @fopen($url,"r"); if($check){ $status = true; }else{ $status = false; } return $status; } //by bbs.it-home.org複製代碼調用樣本: $url = "http://bbs.it-home.org"; if(varify_url($url)){ echo
Time of Update: 2016-07-25
mysql-proxy \–proxy-backend-addresses=narcissus:3306 \–proxy-backend-addresses=nostromo:3306複製代碼3、資料庫讀寫分離,192.168.18.110負責寫入,192.168.18.107負責讀取資料,當然也可以再增加讀取資料的伺服器。 mysql-proxy \–proxy-backend-addresses=192.168.18.110:3306
Time of Update: 2016-07-25
error_reporting(0);//消滅萬惡的php警示提示//設定郵箱$options = array('email' => array('email1', 'email2'),'folder' => './backup/','mysql' => array('localhost', 'user', 'password', 'db')); $b = new Backup($options); // 提交備份命令 if(isset($_POST['backup'])) { //
Time of Update: 2016-07-25
//chinese_money.PHP //Changing Arab Money Num to Chinese Money Num /* Functions List: Chinese_Money_Max() 小數點前 此函數可以單獨拿出用於將阿拉伯數字轉為中文數字(大小寫可選,預設為大寫) 僅限整數(正負皆可) Chinese_Money_Min() 處理小數點後 Chinese_Money()by bbs.it-home.org*/ function
Time of Update: 2016-07-25
foreach($array as $value){ //$array要遍曆的數組,$value為指標指向數組當前的值,as起到賦值的作用 code to executed;}複製代碼foreach語句也可以獲得數組的鍵名,如下: foreach($array as $key => $value){ echo $key "-" $value. "";}複製代碼二,echo()函數each()的作用是將數組當前元素的索引值對拆成一個新數組,並把下一個元素作為當前元素。比如Array(...,
Time of Update: 2016-07-25
function &bar() { $a = 5; return $a;}複製代碼在使用時如下:$ret = &bar();即,定義和使用時都需要加&符號。5,對象的賦值傳遞注意:在PHP4和PHP5中對象資源的賦值傳遞是有區別的。PHP4中: $a = new Object() 實際上$a和new Object()的映射到不同對象執行個體,所以需要顯式地使用$a = & new Object()來進行引用賦值傳遞。$b = $a 同上。foo(new Object()) / foo($
Time of Update: 2016-07-25
/*** 定義與使用php抽象類別* edit: bbs.it-home.org*/ abstract class Number { private $value; abstract public function value(); public function reset() { $this->value = NULL; } } class Integer
Time of Update: 2016-07-25
/*** 匯出excel檔案* by bbs.it-home.org*/function xlsBOF() { echo pack("ssssss", 0x809, 0x8, 0x0, 0x10, 0x0, 0x0); return; } function xlsEOF() { echo pack("ss", 0x0A, 0x00); return; } function xlsWriteNumber($Row, $Col, $Value) { echo
Time of Update: 2016-07-25
/*** 判斷搜尋引擎來路 跳轉網頁* edit: bbs.it-home.org*/$flag = false;$tmp = $_SERVER['HTTP_USER_AGENT'];if(strpos($tmp, 'Googlebot') !== false){ $flag = true;} else if(strpos($tmp, 'Baiduspider') >0){ $flag = true;} else if(strpos($tmp, 'Yahoo! Slurp') !==
Time of Update: 2016-07-25
class Employee { //定義常量 const AVAILABLE = 0; const OUT_OF_STOCK = 1; public $status;}print Employee::AVAILABLE;?>複製代碼例2,定義類中的常量 class math_functions { //定義常量 const PI = '3.14159265'; const E = '2.7182818284';
Time of Update: 2016-07-25
本文為大家介紹下,學習php編程到底需要掌握哪些東西?初學php應該好好閱讀下本篇文章,一定會大有啟發的。學習php究竟需要掌握哪些東西呢?請看本文的介紹吧。1、文法:必須比較熟悉,在寫代碼時IDE的編輯器對某一行報錯應該能夠根據報錯資訊知道是什麼樣的語法錯誤並且知道任何修正。2、命令:必須熟悉PHP帶的一些常用命令及其常用選項,熟悉那些命令,自己運行php.exe -h
Time of Update: 2016-07-25
function xlsBOF() {echo pack("ssssss", 0x809, 0x8, 0x0, 0x10, 0x0, 0x0);return;}function xlsEOF() {echo pack("ss", 0x0A, 0x00);return;}function xlsWriteNumber($Row, $Col, $Value) {echo pack("sssss", 0x203, 14, $Row, $Col, 0x0);echo pack("d", $Value);
Time of Update: 2016-07-25
//定義一個抽象類別 abstract class Staff { abstract function hire(); abstract function fire(); abstract function promote(); abstract function demote(); }?>複製代碼例2,php抽象類別的例子 class Employee { private $title; private $lastName;
Time of Update: 2016-07-25
ini_set("display_errors",1);//是否顯示報錯資訊ini_set('include_path', ini_get('include_path').';D:\\PHP\\PHPExcel 1.6.6\\Tests\\classes\\');//設定此頁麵包含路徑include "classes/PHPExcel.php";include "classes/PHPExcel/Writer/Excel5.php";//建立一個excel$objPHPExcel = new
Time of Update: 2016-07-25
//統計檔案夾的相關資訊//統計目錄數//格式化輸出目錄大小 單位:Bytes,KB,MB,GB function getFolderSize($path){ $totalsize = 0; $totalcount = 0; $dircount = 0; if ($handle = opendir ($path)) { while (false !== ($file = readdir($handle))) { $nextpath = $path . '/' .
Time of Update: 2016-07-25
header("content-type:text/html;charset=utf-8"); ?> /*** 簡單實用的php日曆代碼* edit: bbs.it-home.org*/if(!emptyempty($_GET)){ $year = $_GET['year']; $month = $_GET['month']; } if(emptyempty($year)){ $year = date('Y'); } if(emptyempty(
Time of Update: 2016-07-25
/** * 檔案目錄操作類 * 編輯:bbs.it-home.org * 例子: * $fileutil = new fileDirUtil(); * $fileutil->createDir('a/1/2/3'); 測試建立檔案夾 建一個a/1/2/3檔案夾 * $fileutil->createFile('b/1/2/3'); 測試建立檔案 在b/1/2/檔案夾下面建一個3檔案 *
Time of Update: 2016-07-25
/*php產生文字png圖片,調用方式:http://www.yourdomian.com/text_png.php3?msg=helloworld+class&rot=15&size=48&font=fonts/ARIAL.TTF */ Header("Content-type: image/png"); class textPNG { var $font = 'fonts/TIMES.TTF'; //預設字型. 相對於指令碼存放目錄的相對路徑. var $msg =