Time of Update: 2016-07-25
實現php檔案安全下載! public function downloads($name){ $name_tmp = explode("_",$name); $type = $name_tmp[0]; $file_time = explode(".",$name_tmp[3]); $file_time = $file_time[0]; $file_date = date("Y/md",$file_time);
Time of Update: 2016-07-25
效能一直是 Laravel 架構為人詬病的一個點,所以調優 Laravel 程式算是一個必學的技能。 接下來分享一些開發的最佳實務www.itxdl.cn,還有調優技巧,大家有別的建議也歡迎留言討論。 這裡是簡單的列表: 配置資訊緩衝 artisan config:cache 路由緩衝 artisan route:cache 類映射載入最佳化 artisan optimize 自動載入最佳化 composer dumpautoload 使用 Memcached 來儲存會話
Time of Update: 2016-07-25
[PHP]代碼 class Request{ public static function post($url, $post_data = '', $timeout = 5){//curl $ch = curl_init(); curl_setopt ($ch, CURLOPT_URL, $url); curl_setopt ($ch, CURLOPT_POST, 1); if($post_data != ''){
Time of Update: 2016-07-23
/** * @author Administrator * */class TestGenerate {public static $appFolder = "";public static $ignoreFilePaths = array ("xxxx/xxx.php" );public static function start() {$AppPath = "E:\\myApp";TestGenerate::$appFolder = $AppPath;$destManifestPath
Time of Update: 2016-07-23
最近一個項目中使用php作為為前端提供資料的開發語言,為了實現能夠按照字母排序,需要提取中文的漢語拼音,借這個項目寫了個漢字轉拼音的指令碼,指令碼比較簡單,注釋也比較詳細,這裡就不多說了,直接上代碼了。 使用方法: $py = new PinYin(); $all_py = $py->get_all_py("吳國偉"); //輸出 ['wu','guo','wei'],輸出字串調用join方法,join('',$all_py) $first_py =
Time of Update: 2016-07-23
SimpleDao.class //require_once('FirePHPCore/FirePHP.class.php'); //$firephp = FirePHP::getInstance(true); // debugger in firefox class SimpleDao { private $_table = null; private static $_con = null; public
Time of Update: 2016-07-23
[PHP]代碼 /** * 人民幣小寫轉大寫 * * @param string $number 數值 * @param string $int_unit 幣種單位,預設"元",有的需求可能為"圓" * @param bool $is_round 是否對小數進行四捨五入 * @param bool $is_extra_zero 是否對整數部分以0結尾,小數存在的數字附加0,比如1960.30, *
Time of Update: 2016-07-25
判斷訪問IP php代碼 function getIP() { if (! empty ( $_SERVER ["HTTP_CLIENT_IP"] )) { $cip = $_SERVER ["HTTP_CLIENT_IP"]; } else if (! empty ( $_SERVER ["HTTP_X_FORWARDED_FOR"] )) { $cip = $_SERVER ["HTTP_X_FORWARDED_FOR"]; }
Time of Update: 2016-07-25
curl雖然功能強大,但是只能偽造$_SERVER["HTTP_X_FORWARDED_FOR"],對於大多數IP地址檢測程式來說,$_SERVER["REMOTE_ADDR"]很難被偽造: 首先是client.php的代碼 01 $headers['CLIENT-IP'] = '202.103.229.40'; 02
Time of Update: 2016-07-25
十個超級有用的php程式碼片段 [PHP]代碼 1. 傳送簡訊調用 TextMagic API。// Include the TextMagic PHP librequire('textmagic-sms-api-php/TextMagicAPI.php');// Set the username and password information$username = 'myusername';$password = 'mypassword';// Create a new
Time of Update: 2016-07-25
[PHP]代碼 //blog.qita.inecho 'md5檢驗[目錄直接md5目錄名稱,檔案就md5_file整個檔案的內容]';$filename = "test.txt";if(is_dir($filename)){ $md5file = md5($filename);}else{ $md5file = md5_file($filename);}echo $md5file;//儲存原始檔案的md5值到md5file.txt檔案//file_put_contents("md5
Time of Update: 2016-07-25
使用php來實現telnet的串連、傳遞命令、擷取傳回值等功能! telnet.php error_reporting(-1);class Telnet { var $sock = NULL; function telnet($host,$port) { $this->sock = fsockopen($host,$port); socket_set_timeout($this->sock,2,0); } function close() { if ($this->sock)
Time of Update: 2016-07-25
php擷取首字母 [PHP]代碼 $d = array( array("a",-20319), array("ai",-20317), array("an",-20304), array("ang",-20295), array("ao",-20292), array("ba",-20283), array("bai",-20265), array("ban",-20257),
Time of Update: 2016-07-25
他的特點:單純,接受參數,給出分頁;靈活:可以自己決定,上、下一頁的名稱(比如我想叫prev、nex t諸如此類)可以決定每頁展示的分頁數量,跨頁數提供一個封裝方法,適應不同的網頁結構,比如有的網頁我需要每個分頁包含一個li(1 ...),依次類推備忘說明:提供的示範代碼中有兩個靜態方法大家可以不必理會。這個是自己項目開發用的。Call::import,大家可以使用include代
Time of Update: 2016-07-25
[PHP]代碼 /** * http請求處理類(基於CURL進行封裝) * * @author Xiwei Ye * @version $Id$ */class cls_http_request{ /** * get方式請求(curl) * * @param string $url 請求的url * @param integer $timeout 逾時時間(s) * @return string(請求成功)
Time of Update: 2016-07-25
[PHP]代碼 class mysql { private $db_host; //資料庫主機 private $db_user; //資料庫使用者名稱 private $db_pwd; //資料庫使用者名稱密碼 private $db_database; //資料庫名 private $conn; //資料庫連接標識; private $result; //執行query命令的結果資源標識 private $sql; //sql執行語句
Time of Update: 2016-07-25
一個簡單的PDO類封裝。。僅供學習交流 PdoDb 資料庫類 /** * @throws Error * PDO資料庫 */class PdoDb extends DatabaseAbstract{ /** * PDO執行個體 * @var PDO */ protected $DB; /** * PDO準備語句 * @var PDOStatement */ protected $Stmt; /** *
Time of Update: 2016-07-25
[PHP]代碼 function g($name, $defaultValue = "") { // php這裡區分大小寫,將兩者都變為小寫 $_GET = array_change_key_case ( $_GET, CASE_LOWER ); $name = strtolower ( $name ); $v = isset ( $_GET [$name] ) ? $_GET [$name] : ""; if ($
Time of Update: 2016-07-25
項目中需要將表中的資料匯出,在網上找了找發現phpexcel蠻好用的.特此分享 PHPEXCEL if(!defined('BASEPATH')) exit('No direct script access allowed');//物資發料單明細class Read_write{ /** * $name:選擇的類型(CSV,EXCEL2003,2007) * $titles:標題數組 * $querys:查詢返回的數組 $query->result_
Time of Update: 2016-07-25
效果:今天是:星期五今天是:禮拜五2010-12-12是:禮拜日 [PHP]代碼 function getWeekName($data,$format = '星期'){ $week = date( "D ",$data); switch($week) { case "Mon ": $current = $format."一"; break; case "Tue ":