Time of Update: 2016-07-25
使用下面的函數可以擷取任何網域名稱使用者的完整細節 function whois_query($domain) { // fix the domain name: $domain = strtolower(trim($domain)); $domain = preg_replace('/^http:\/\//i', '', $domain); $domain = preg_replace('/^www\./i', '', $domain); $domain =
Time of Update: 2016-07-25
function getRealIpAddr() { if (!emptyempty($_SERVER['HTTP_CLIENT_IP'])) { $ip=$_SERVER['HTTP_CLIENT_IP']; } elseif (!emptyempty($_SERVER['HTTP_X_FORWARDED_FOR'])) //to check ip is pass from proxy {
Time of Update: 2016-07-25
$dir = './'; // set to current folderif ($handle = opendir($dir)) { while(false!== ($file = readdir($handle))) { if ( is_file($dir.$file) ){ if (preg_match("'\.(avi)$'", $file) ){ $sub_file = str_ireplace(".avi", ".srt", $dir.$file); $idx_file = str_
Time of Update: 2016-07-25
$f = file('words.txt');$words = array();foreach ($f as $w) { $words[] = preg_quote(trim($w), '/');}$text = file_get_contents('text.txt'); $start = microtime(true);$reg = '/' . implode('|', $words) . '/S'; preg_match_all($reg, $text, $m); $result =
Time of Update: 2016-07-25
/** * 下載遠程圖片到本地 * * @param string $url 遠程檔案地址 * @param string $filename 儲存後的檔案名稱(為空白時則為隨機產生的檔案名稱,否則為原檔案名稱) * @param array $fileType 允許的檔案類型 * @param string $dirName 檔案儲存的路徑(路徑其餘部分根據時間系統自動產生) * @param int $type 遠程擷取檔案的方式 * @return json 返迴文件名、檔案的儲存路徑 *
Time of Update: 2016-07-25
$image=imagecreatetruecolor(100, 30);$white=imagecolorallocate($image, 255, 255, 2);$red=imagecolorallocate($image, 255, 0, 0);imagefill($image, 0, 0, $white);//munber create$num="";for($i=0;$i $num.=rand(1,9);}imagestring($image, 6, rand(10,
Time of Update: 2016-07-25
$img=imagecreatetruecolor(100, 40);$red=imagecolorallocate($img, 255, 0, 0);$green=imagecolorallocate($img, 0, 255, 0);$blue=imagecolorallocate($img, 0, 0, 255);$white=imagecolorallocate($img, 255, 255, 255);$black=imagecolorallocate($img, 0, 0, 0);/
Time of Update: 2016-07-25
本文執行個體講述了phpRegex取得內容所有連結的方法。分享給大家供大家參考。具體如下: 這裡提供二款關於php正則連結的方法,他們可以取得內容所有連結並且儲存到一個數組,當然也可以把連結全部替換. 方法一,代碼如下: function get_all_url($code){ preg_match_all('/"' ]+)["|']?s*[^>]*>([^>]+)/i',$code,$arr); return array('name'=>$arr[2],
Time of Update: 2016-07-25
/** * auther soulence * 調用資料類檔案 * modify 2015/06/12 */class DBConnect{ private $dbname = null; private $pdo = null; private $persistent = false; private $statement = null; private $lastInsID = null; private static $_instance = [];
Time of Update: 2016-07-25
/** * */ function getfirstchar($s0){ if($s0[0]=='I' || $s[0]=='i'){ return "I"; }elseif($s0[0]=='U' || $s[0]=='u'){ return 'U'; }elseif($s0[0]=='V' ||
Time of Update: 2016-07-25
//擷取指定URL頁面中所有連結 function get_url_href($url){ $html = file_get_contents($url); $dom = new DOMDocument(); @$dom->loadHTML($html); $xpath = new DOMXPath($dom); $hrefs = $xpath->evaluate('/html/body//a')
Time of Update: 2016-07-25
一、基本知識 通過使用 PHP 的全域數組 $_FILES,你可以從客戶電腦向遠程伺服器上傳檔案。 第一個參數是表單的 input name,第二個下標可以是 "name", "type", "size", "tmp_name" 或 "error"。就像這樣: $_FILES["file"]["name"] - 被上傳檔案的名稱 $_FILES["file"]["type"] - 被上傳檔案的類型 $_FILES["file"]["size"
Time of Update: 2016-07-25
/** desc:採集網頁中的郵箱的代碼 */ $url='http://www.xxx.net'; //要採集的網址 $content=file_get_contents($url); //echo $content; function getEmail($str) { //$pattern =
Time of Update: 2016-07-25
function unzip($location,$newLocation){ if(exec("unzip $location",$arr)){ mkdir($newLocation); for($i = 1;$i $file = trim(preg_replace("~inflating: ~","",$arr[$i])); copy($location.'/'.$file,
Time of Update: 2016-07-25
/** * * User: jifei * Date: 2013-07-31 * Time: 23:19 *//** * Class Singleton * 單例模式,也叫單子模式,是一種常用的軟體設計模式。在應用這個模式時,單例對象的類必須保證只有一個執行個體存在, * 充分體現了 DRY(Don't Repeat Yourself)的思想。 * *
Time of Update: 2016-07-25
BOM: Byte Order Mark UTF-8 BOM又叫UTF-8 簽名,其實UTF-8 的BOM對UFT-8沒有作用,是為了支援UTF-16 ,UTF-32才加上的BOM,BOM簽名的意思就是告訴編輯器當前檔案採用何種編碼,方便編輯器識別,但是BOM雖然在編輯器中不顯示,但是會產生輸出,就像多了一 個空行,如果您在修改任何PHP檔案後發生: 不能登入或者不能登出; * 頁頂出現一條空白; * 頁頂出現錯誤警告;
Time of Update: 2016-07-25
function dominant_color($image){$i = imagecreatefromjpeg($image);for ($x=0;$x for ($y=0;$y $rgb = imagecolorat($i,$x,$y); $r = ($rgb >> 16) & 0xFF; $g = ($rgb >> & 0xFF; $b = $rgb & 0xFF; $rTotal += $r;
Time of Update: 2016-07-25
對象複製的由來 為什麼對象會有“複製”這個概念,這與PHP5中對象的傳值方式是密切相關的,讓我們看看下面這段簡單的代碼 php代碼 * /** * * 電視機類 * */ * class Television * { * /** * * 螢幕高度 * */ * protected $_screenLength = 300
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
效果:今天是:星期五今天是:禮拜五2010-12-12是:禮拜日 [PHP]代碼 function getWeekName($data,$format = '星期'){ $week = date( "D ",$data); switch($week) { case "Mon ": $current = $format."一"; break; case "Tue ":