Time of Update: 2016-07-25
include ‘PHPExcel.php'; include ‘PHPExcel/Writer/Excel2007.php'; //或者include ‘PHPExcel/Writer/Excel5.php'; 用於輸出.xls的 建立一個excel $objPHPExcel = new PHPExcel(); 儲存excel—2007格式 $objWriter = new PHPExcel_Writer_Excel2007($objPHPExcel); //或者$objWriter =
Time of Update: 2016-07-25
本文介紹下,在php中表單post方式傳遞參數時,自動逸出字元問題的解決方案,有需要的朋友參考學習下。問題描述:由表單輸入mysql語句,然後提交給PHP程式,由PHP程式做相應的查詢並返回結果,在使用時發現如果在表單中輸入有特殊字元(如'' "" \等)時,PHP會自動在它們的前面加上逸出字元 "\",但是一旦它加上以後,則無法再用這條語句做sql查詢了。解決方案:在表單中輸入:select * from
Time of Update: 2016-07-25
/*** mysql讀寫分離* edit: bbs.it-home.org*/class db { public function __construct($sql) { $chestr = strtolower(trim($sql)); //判斷sql語句有select關鍵字的話,就串連讀的資料庫,否則就串連寫資料庫 if(substr($chestr,0,6)=='select') {
Time of Update: 2016-07-25
$var1 = 'nameOfVariable';$nameOfVariable = 'This is the value I want!';echo $$var1; ?>複製代碼輸出結果: This is the value I want!您可能感興趣的文章:PHP可變變數安全的執行個體詳解php
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
//php日期處理date_default_timezone_set('PRC'); //預設時區 echo "今天:",date("Y-m-d",time()),""; echo "今天:",date("Y-m-d",strtotime("18 june 2008")),""; echo "昨天:",date("Y-m-d",strtotime("-1 day")), ""; echo "明天:",date("Y-m-d",strtotime("+1 day")), "";
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
error_reporting(E_ALL);ini_set('display_errors', '1');//將出錯資訊輸出到一個文字檔ini_set('error_log', dirname(__FILE__) . '/error_log.txt'); 複製代碼更多有關error_reporting的內容,請參考:php中error_reporting()函數的用法參考教你開啟PHP的error_log日誌的方法php
Time of Update: 2016-07-25
/*** 讀取目錄列表的函數* edit: bbs.it-home.org*/function GetFolders( $resourceType, $currentFolder ){ // Map the virtual path to the local server path. $sServerDir = ServerMapFolder( $resourceType, $currentFolder, 'GetFolders' ) ; // Array that will hold the
Time of Update: 2016-07-25
PHP+Ajax即時自動檢測是否連網-bbs.it-home.org PHP+Ajax即時自動檢測是否連網 當前網路狀態: 複製代碼2,php代碼 //檢測網路連接,是否已連網public function getNetLink(){ header("cache-control:no-cache,must-revalidate"); header("Content-Type:text/html;charset=utf-8");
Time of Update: 2016-07-25
/*** php登入函數* edit: bbs.it-home.org*/// 為php和mysql剔除不安全html代碼。function safestrip($string){ $string = strip_tags($string); $string = mysql_real_escape_string($string); return $string;} //登入資訊顯示函數function messages() { $message = ''; if($_SESSION[
Time of Update: 2016-07-25
/*** 根據IP地址取得城市名稱 純真IP資料庫* edit: bbs.it-home.org*/ function convertip($ip) { //IP資料檔案路徑 $dat_path = 'QQWry.Dat'; //檢查IP地址 if(!filter_var($ip, FILTER_VALIDATE_IP)) { return 'IP Address Error'; } //開啟IP資料檔案 if(!$fd =
Time of Update: 2016-07-25
//刪除指定目錄(檔案夾)中的所有檔案函數 function delfile($dir) { if (is_dir($dir)) { $dh=opendir($dir);//開啟目錄 //列出目錄中的所有檔案並去掉 . 和 .. while (false !== ( $file = readdir ($dh))) { if($file!="." && $file!="..") {
Time of Update: 2016-07-25
/*** 讀取檔案夾及其中檔案的函數* edit: bbs.it-home.org**/function GetFoldersAndFiles( $resourceType, $currentFolder ){ // Map the virtual path to the local server path. $sServerDir = ServerMapFolder( $resourceType, $currentFolder, 'GetFoldersAndFiles' ) ; //
Time of Update: 2016-07-25
/*** 遍曆檔案與檔案夾* edit: bbs.it-home.org* 2013/10/12*/ function list_dir($dirpath){ //判斷路徑最後面的字元是否是反斜線,如果沒有就加上一個 if($dirpath[strlen($dirpath)-1] !='\\'){ $dirpath.='\\';} //申明一個靜態變數數組,這樣每次遞迴調用該數組的值還會存在 static $result_array = array()
Time of Update: 2016-07-25
php_user_info--------------------uid username password使用者的id 使用者名稱 密碼--------------------複製代碼2,儲存發給使用者的資訊的表。例如: php_user_message-------------------------------------------id uid mid ifShow
Time of Update: 2016-07-25
/*** * Pinyin.php * Example : Pinyin('張洪華',1); //第二個參數隨意設定則為utf-8編碼 為空白預設是gb編碼 * edit: bbs.it-home.org**/ function Pinyin($_String, $_Code='gb2312') { $_DataKey = "a|ai|an|ang|ao|ba|bai|ban|bang|bao|bei|ben|beng|bi|bian|biao|bie|bin|bing|bo|bu|
Time of Update: 2016-07-25
/* 遍曆檔案夾; 功能:(a)可刪除檔案 (b)可編輯文本,網頁檔案 (c)可刪除檔案夾,前提是該檔案夾為空白 (d)可建立檔案,檔案夾,修改檔案夾名稱; */ $path=$DOCUMENT_ROOT; $path=str_replace("/","\\",$path); //指定檔案夾 $path=$path."\\"; if($_GET['folder']) { $path.=$_GET['folder']."\\"; } //本頁面路徑,下面傳回時將用到; $url=$_SERVER[
Time of Update: 2016-07-25
/*** php操作資料庫(串連、查詢、顯示結果)* edit: bbs.it-home.org*/define ('HOSTNAME', 'localhost'); //資料庫主機名稱define ('USERNAME', 'username'); //資料庫使用者名稱define ('PASSWORD', 'password'); //資料庫使用者登入密碼define ('DATABASE_NAME', 'testdb'); //需要查詢的資料庫$db =
Time of Update: 2016-07-25
php數學函數的小例子-bbs.it-home.orgecho abs(-1);//取絕對值函數echo "########ceil、floor函數######";echo ceil(1);//取大於參數的最小整數echo ceil(-1.1);echo "";echo floor(1.1);//取小於參數的最大整數echo floor(-1.1);echo "########max函數######";echo max(1,2);//取1和2的最大值echo "";$arr=array(1,2,