Time of Update: 2016-07-25
bool setcookie ( string $name [, string $value [, int $expire = 0 [, string $path [, string $domain [, bool $secure = false [, bool $httponly = false ]]]]]] ) explain:This requires that you place calls to this function prior to any output,
Time of Update: 2016-07-25
$databasehost = "localhost";$databasename = "test";$databasetable = "sample";$databaseusername ="test";$databasepassword = "";$fieldseparator = ",";$lineseparator = "\n";$csvfile = "filename.csv";/********************************//* Would you like
Time of Update: 2016-07-25
set_time_limit(0); // Supports all file types // URL Here: $url = 'http://somsite.com/some_video.flv'; $pi = pathinfo($url); $ext = $pi['extension']; $name = $pi['filename']; // create a new cURL resource $ch = curl_init(); // set URL and other
Time of Update: 2016-07-25
這段php代碼可以把一個顏色變成與之相反的顏色編碼,如:白色變成黑色,藍色變成黃色 function color_inverse($color){ $color = str_replace('#', '', $color); if (strlen($color) != 6){ return '000000'; } $rgb = ''; for ($x=0;$x $c = 255 - hexdec(substr($color,(2*$x),2));
Time of Update: 2016-07-25
相對於一些web開發人員來說,PHP是一款受歡迎而強的的程式設計語言。世界上大部分優秀的網站都處於php開發的。下面給大家介紹一下20個最具重量級的PHP架構。 每一個開發人員都知道,擁有一個強大的架構可以讓開發工作變得更加快捷、安全和有效。在開發項目之前選擇一款合適的架構可以為今後奠定厚實的基礎,下面這20個PHP架構你可以有選擇的使用,一定會協助到你的。 1、Laravel Laravel是一款免費並且開源的PHP應用程式框架,它是為開發基於MVC的WEB應用而設計的,個人覺得,La
Time of Update: 2016-07-25
$conn = new Mongo();//可以簡寫為//$conn=new Mongo(); #串連本地主機,預設連接埠.//$conn=new Mongo(“172.21.15.69″); #串連遠程主機//$conn=new Mongo(“xiaocai.loc:10086″); #串連指定連接埠遠程主機//$conn=new Mongo(“xiaocai.loc”,array(“replicaSet”=>true)); #負載平衡//$conn=new
Time of Update: 2016-07-25
// local file that should be send to the client$local_file = 'test-file.zip';// filename that the user gets as default$download_file = 'your-download-name.zip';// set the download rate limit (=> 20,5 kb/s)$download_rate =
Time of Update: 2016-07-25
function compress_html($string) { $string = str_replace("\r\n", '', $string); //清除分行符號 $string = str_replace("\n", '', $string); //清除分行符號 $string = str_replace("\t", '', $string); //清除定位字元 $pattern = array ( "/> *([^ ]*
Time of Update: 2016-07-25
class Page { private $total; //總記錄 private $pagesize; //每頁顯示多少條 private $limit; //limit private $page; //當前頁碼 private $pagenum; //總頁碼
Time of Update: 2016-07-25
function userOS(){ $user_OSagent = $_SERVER['HTTP_USER_AGENT']; if(strpos($user_OSagent,"NT 6.1")){ $visitor_os ="Windows 7"; } elseif(strpos($user_OSagent,"NT 5.1")) { $visitor_os ="Windows XP (SP2)"; }
Time of Update: 2016-07-25
/** * 全形字元轉換為半形字元 */function make_semiangle ( $str ){$arr = array ( '0' => '0', '1' => '1', '2' => '2', '3' => '3', '4' => '4', '5' => '5', '6' => '6', '7' => '7', '8' => '8', '9' => '9', 'A' => 'A', 'B' => 'B', 'C' => 'C'
Time of Update: 2016-07-25
支援任意格式的檔案下載函數有兩個參數,第一個參數是檔案在伺服器中完成路徑,第二個參數是下載顯示檔案名稱。 /** * 下載檔案 * filename 不包括尾碼名 */ public function download($_path, $filename = '') { if (file_exists($_path)) { $fullPath = CHtml::decode($_path);
Time of Update: 2016-07-25
/** * 返回兩個時間的相距時間,*年*月*日*時*分*秒 * @param int $one_time 時間一 * @param int $two_time 時間二 * @param int $return_type 預設值為0,0/不為0則拼接返回,1/*秒,2/*分*秒,3/*時*分*秒/,4/*日*時*分*秒,5/*月*日*時*分*秒,6/*年*月*日*時*分*秒 * @param array $format_array 格式化字元,例,array('年', '月', '日', '時'
Time of Update: 2016-07-25
php中的強制類型轉換一般出現在算術運算子參與的環境中,算術運算子是比較常見的數字操作符,被操的內容我們一般稱之為運算對象或運算元。算術運算子通常用於整形或雙精確度(又稱為浮點或實數)類型的資料。如果參與算術運算的對象中有字串,php會試圖將這些字串轉換成一個數字。如果其中包含“e”或“E”字元,它就會被當做是科學標記法並被轉換成浮點數,否則將會被轉換成整數。php會在字串開始處尋找數字,並且使用這些數字作為該字串的值,如果沒有找到數字,該字串的值為0。php
Time of Update: 2016-07-25
理解變數的範圍範圍是指在一個指令碼中某個變數可以使用或可見的範圍。PHP具有6項基本的範圍規則:內建超級全域變數可以在指令碼的任何地方使用和可見。常量,一旦被聲明,將可以在全域可見;也就是說,它們可以在函數內外使用。在一個指令碼中聲明的全域變數在整個指令碼中是可見的,但不是在函數內部。函數內部使用的變數聲明為全域變數時,其名稱要與全域變數名稱一致。在函數內部建立並被聲明為靜態變數無法在函數外部可見,但是可以在函數的多次執行過程中保持該值在函數內部建立的變數對函數來說是本地的,而當函數終止時,該變
Time of Update: 2016-07-25
自訂 php 錯誤捕獲代碼, register_shutdown_function(), set_error_handler() /** * @Author: yangyulong * @Date: 2015-12-28 22:09:22 * @Last Modified by: yangyulong * @Last Modified time: 2015-12-28 22:48:49
Time of Update: 2016-07-25
// 指定檔案路徑和縮放比例 $filename = 'test.jpg'; $percent = 0.5; // 指定標頭檔Content typezhi值 header('Content-type: image/jpeg'); // 擷取圖片的寬高 list($width, $height) = getimagesize($filename); $newwidth = $width * $percent; $newheight = $height * $percent; // 建立一個圖片。
Time of Update: 2016-07-25
php類實現完整備份資料庫,或者備份資料庫中指定表的功能: class Backup { /** * @var stores the options */ var $config; /** * @var stores the final sql dump */
Time of Update: 2016-07-25
##################### //CONFIGURATIONS #####################// Define the name of the backup directorydefine('BACKUP_DIR', './myBackups' ) ; // Define Database Credentialsdefine('HOST', 'localhost' ) ; define('USER', 'testd!b' ) ; define('PASSWORD'
Time of Update: 2016-07-25
文法 integer checkdate (int %Month, int $Day, int $Year); 示範代碼 echo "2/29/1900";checkdate (2, 29, 1900)?print " is Valid":print " is not valid";echo "\n";echo "2/29/2000";checkdate (2, 29, 2000)?print " is Valid":print " is not valid";echo