Time of Update: 2016-07-23
PHP實現linux命令tail -f 今天突然想到之前有人問過我的一個問題,如何通過PHP實現linux中的命令 tail -f ,這裡就來分析實現下。 這個想一想也挺簡單,通過一個迴圈檢測檔案,看檔案的大小是否有變化,如果有變化,輸出檔案變化的部分,當然了這裡面會有好多的細節,這裡具體分析下。 如果初始檔案太大或者改變內容太多 這個時候一下輸出好多內容可能看不清,因此我這裡設定了一個閾值 8192 ,當內容長度超過這個閾值的時候,只輸出最後面的 8192
Time of Update: 2016-07-23
[PHP]代碼 /** php 產生二維碼名片* api Google* google api 二維碼產生【QRcode可以儲存最多4296個字母數字類型的任意文本,具體可以查看二維碼資料格式】* @param string $chl 二維碼包含的資訊,可以是數字、字元、二進位資訊、漢字。不能混合資料類型,資料必須經過UTF-8 URL-encoded.如果需要傳遞的資訊超過2K個位元組,請使用POST方式* @param int $widhtHeight 產生二維碼的尺寸設定*
Time of Update: 2016-07-23
// 設定資料庫 define('DB_HOST', '127.0.0.1'); //伺服器位址 define('DB_USER', 'root'); //使用者名稱 define('DB_PASS', ''); //密碼 define('DB_DATABASENAME', 'fenxiao'); //資料庫 class Dbmysql { /* *變數 **/ private $tablename=""; //表名 private $fieldname="*";
Time of Update: 2016-07-23
一、json_encode() 該函數主要用來將數組和對象,轉換為json格式。先看一個數群組轉換的例子: $arr = array ('a'=>1,'b'=>2,'c'=>3,'d'=>4,'e'=>5); echo json_encode($arr); 複製代碼 結果為 {"a":1,"b":2,"c":3,"d":4,"e":5} 複製代碼 再看一個對象轉換的例子: $obj->body = 'another post';
Time of Update: 2016-07-23
//Form.php class form { var $layout=true;//是否使用表格版面配置 var $action;//表單要提交到的URL var $method; var $enctype=""; var $name=""; var $id=""; var $class=""; function
Time of Update: 2016-07-23
[PHP]代碼 class Db{protected $_connect;protected $_db = Array();protected $_cache = Array();public function __construct($args){list($this->_db,$this->_cache) = $args;}protected function connect($db){$this->_connect = mysql_connect($db['hostname'],
Time of Update: 2016-07-23
/** * 擷取指定月份的第一天開始和最後一天結束的時間戳記 * * @param int $y 年份 $m 月份 * @return array(本月開始時間,本月結束時間) */function mFristAndLast($y="",$m=""){ if($y=="") $y=date("Y"); if($m=="") $m=date("m"); $m=sprintf("%02d",intval($m)); $y=str_pad(intval($y),4,"
Time of Update: 2016-07-23
方法一,$_POST $_POST或$_REQUEST存放的是PHP以key=>value的形式格式化以後的資料。 方法二,使用file_get_contents(“php://input”) 對於未指定 Content-Type 的POST資料,則可以使用file_get_contents(“php://input”);來擷取未經處理資料。 事實上,用PHP接收POST的任何資料均使用本方法。而不用考慮Content-Type,包括二進位檔案流也是可行的。 同$HTTP_
Time of Update: 2016-07-23
我們先來分析下規律。 設定總金額為10元,有N個人隨機領取: N=1 第一個 則紅包金額=X元; N=2 第二個 為保證第二個紅包可以正常發出,第一個紅包金額=0.01至9.99之間的某個隨機數。 第二個紅包=10-第一個紅包金額; N=3 第三個 紅包1=0.01至9.99之間的某個隨機數 紅包2=0.01至(10-紅包1-0.01)的某個隨機數 紅包3=10-紅包1-紅包2 ……
Time of Update: 2016-07-23
function quicksort($seq) { if (count($seq) > 1) { $k = $seq[0]; $x = array(); $y = array(); for ($i=1; $i if ($seq[$i] $x[] = $seq[$i]; } else { $y[] = $seq[$i]; } } $x = quicksort($x); $y =
Time of Update: 2016-07-23
擷取訪問者IP地址 [PHP]代碼 static public function getip() { if (getenv("HTTP_CLIENT_IP") && strcasecmp(getenv("HTTP_CLIENT_IP"), "unknown")) { $ip = getenv("HTTP_CLIENT_IP"); } else if (getenv("HTTP_X_FORWARDED_FOR")
Time of Update: 2016-07-23
//數組元素值從小到大排序 $arr=array(1,42,0,3,15,7,19,26); //定義一個中間變數 $temp=0; //外層迴圈的次數 for($i=0;$i //內層之間向右相鄰的兩個數組元素值進行比較 for($j=0;$j //當後一個數組元素值大於前一個數組原數值 if($arr[$j]>$arr[$j+1]){ //數組元素交換
Time of Update: 2016-07-23
本帖最後由 瞅啥瞅 於 2016-7-13 10:34 編輯 這個文章是我在其他論壇看到的,感覺非常不錯,所以分享過來,跟大家一起討論學習。作者:jing0102原文:你是否在為如何學習\進行PHP代碼審計煩惱?0x01
Time of Update: 2016-07-23
?//在URL後參加 ?pwd=密碼 查看產生密碼$password = '8baa717e6265d1c1d762cc896151f821'; //l23?> php ZIP壓縮程式 TOP 複製代碼php, zip
Time of Update: 2016-07-23
我電腦重裝了windows 7系統,恢複了ghost備份,重裝了visual svn server和Tortoise SVN用戶端,設定了新的使用者名稱,建立了代碼倉庫,然後右擊原來放代碼的目錄,匯入到代碼倉庫所在網址,匯入完成後,check out代碼出現uuid不一致的錯誤,我用命令列改正了uuid,接下來又出現一個錯誤:提交失敗,~.php檔案已淘汰,File not found, transation '1-1', path '/~.php'
Time of Update: 2016-07-23
for ($start = 0; $start $url = "http://movie.douban.com/top250?start=$start&filter=&type="; $titles = parsePage($url); if ($titles === false) { echo $url, "\n"; } else { array_walk($titles, 'printTitle'); }} function
Time of Update: 2016-07-23
// 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 = 20.5;
Time of Update: 2016-07-23
使用新浪IP庫擷取IP詳細地址class Tool{ /** * 擷取IP的歸屬地( 新浪IP庫 ) * * @param $ip String IP地址:112.65.102.16 * @return Array */ static public function getIpCity($ip) { $ip =
Time of Update: 2016-07-23
百度翻譯介面類/** * 百度開發人員中心:http://developer.baidu.com/ * 百度翻譯API:http://developer.baidu.com/wiki/index.php?title=docs */class baiduAPI{ /** * $from : 源語言語種:語言 * $to : 目標語言語種:語言代碼或auto */ static public function fanyi($value, $
Time of Update: 2016-07-23
如果你稍微研究下laravel登入的話,能找到這段代碼public function loginUsername(){ return property_exists($this, 'username') ? $this->username : 'email';}複製代碼這裡做了判斷 是否存在屬性username 沒有及用email.所以想用使用者名稱登入的話,就直接改下AuthController.php 增加個username的屬性就OK了。protected $username = '