Time of Update: 2016-07-25
/* * 關鍵詞匹配類 * @author ylx * @packet mipang * 使用執行個體 * $str = "綠殼蛋雞撒範德薩下一年,下一年1的灑落開房間盧卡斯地方軍"; * $key = new KeyReplace($str,array("xxxx"=>"sadf","下一年1"=>'http://baidu.com',"下一年"=>'google.com')); * echo $key->getResultText(); * echo
Time of Update: 2016-07-25
本文分享一個php檔案快取資料類,寫的挺規範挺好的,後面有調用樣本。有需要的朋友參考下。說到php檔案快取,回顧之前介紹的文章,找到了這麼幾篇:php 緩衝類 調用樣本 PHP 資料緩衝的執行個體代碼 php 頁面緩衝類,大家可以參考下。有了以上對於php 檔案快取的基礎,下面開始今天的內容。代碼如下:cachePath = $path; } } /** * 解構函式 */ function
Time of Update: 2016-07-25
本文介紹下,php根據時間進行判斷,以顯示剛剛、幾分鐘前、幾小時前的代碼,有需要的朋友,參考下。判斷資訊發布時間距現在的時間差,轉換顯示成“剛剛”、“幾分鐘前”、“幾小時前”、“昨天”、“前天”。代碼如下:>>> 您可能感興趣的文章:PHP實現時間軸函數(剛剛、5分鐘前)php擷取時間、多少分鐘前的範例程式碼PHP刪除N分鐘前建立的所有檔案的小例子php實現幾分鐘前發布資訊的功能代碼
Time of Update: 2016-07-25
本文介紹下,在php中用range函數,建立包含指定範圍單元的數組的例子,有需要的朋友參考下。之前,我們介紹過一篇 php快速建立數組的方法,其中就用到了php range()函數。本文介紹下,在php中用range函數,建立包含指定範圍單元的數組的例子,有需要的朋友參考下。之前,我們介紹過一篇 php快速建立數組的方法,其中就用到了php range()函數。大家可以參考下,當作本文的熱身吧。本節學習php中 range()函數的用法。例子:說明:array range(mixed
Time of Update: 2016-07-25
本文介紹下,php實現抓取蜘蛛爬蟲痕迹的一段代碼,有需要的朋友參考下。用php程式碼分析web日誌中蜘蛛爬蟲痕迹,代碼如下: 'googlebot', 'Baidu' => 'baiduspider', 'Yahoo' => 'yahoo slurp', 'Soso' => 'sosospider', '
Time of Update: 2016-07-25
/*** 得到當前網址* eidt by bbs.it-home.org*/function get_url() { $sys_protocal = isset($_SERVER['SERVER_PORT']) && $_SERVER['SERVER_PORT'] == '443' ? 'https://' : 'http://'; $php_self = $_SERVER['PHP_SELF'] ? $_SERVER['PHP_SELF'] : $_SERVER['SCRIPT_NAME'
Time of Update: 2016-07-25
本文介紹下,php操作access資料庫的一個類,有需要的朋友參考下。代碼如下: getlist("SELECT TOP 5 * FROM `Result` WHERE `ResultNo` num_rows("update `conner` set `connerip` = '222.35.142.101' where `connerno` databasepath=$databasepath; $this->username=$dbusername; $this-
Time of Update: 2016-07-25
/*** 擷取Google PR值* by bbs.it-home.org*/define('GOOGLE_MAGIC', 0xE6359A60); function zeroFill($a, $b) { $z = hexdec(80000000); if ($z & $a) { $a = ($a>>1); $a &= (~$z); $a |= 0x40000000; $a = ($a>>($b-1)); } else { $a = ($a>>$b); } return $a;
Time of Update: 2016-07-25
/*** sqlite_create_function函數樣本* edit: bbs.it-home.org*/ define("PPO",400); function my($salary){ return $salary / PPO; } $sqldb = sqlite_open("mydatabase.db"); sqlite_create_function($sqldb,"myFunction", "my", 1); $query = "select
Time of Update: 2016-07-25
/*** 短串連產生演算法 * site: bbs.it-home.org*/ class Short_Url { #字元表 public static $charset = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; public static function short($url) { $key =
Time of Update: 2016-07-25
$dbconn = sqlite_open('phpdb'); if ($dbconn) { sqlite_query($dbconn, "CREATE TABLE animal(Name VARCHAR(255), MaxAge INT);"); sqlite_query($dbconn, "INSERT INTO animal VALUES ('A', 15)"); $result =
Time of Update: 2016-07-25
/** * **雙向鏈表 * @author zhiyuan12@ * @modified 2012-10-25 * @site: bbs.it-home.org */ /** * 鏈表元素結點類 */ class Node_Element { public $pre = NULL; // 前驅 public $next = NULL; // 後繼 public $key = NULL; // 元素索引值 public $data =
Time of Update: 2016-07-25
/*** 擷取目前的目錄及子目錄下的所有檔案* @param string $dir 路徑名* @return array 所有檔案的路徑數組*/function get_files1($dir) {$files = array();if(!is_dir($dir)) {return $files;}$handle = opendir($dir);if($handle) {while(false !== ($file = readdir($handle))) {if ($file != '.'
Time of Update: 2016-07-25
/*** 內容關鍵字替換* by bbs.it-home.org*/$arr=array("鞋子"=>"鞋子","襪子"=>"襪子","裙子"=>"裙子","連衣裙"=>"連衣裙",);$str="鞋子 襪子 鞋子 襪子 鞋子 襪子 鞋子 襪子 裙子 連衣裙";$str=replacelink($str,$arr,3);echo $str;public function replacelink($str,$arr,$maxcount=3000){//匹配出圖片preg_match_all("/(
Time of Update: 2016-07-25
header("Content-type: image/png");$temp_width = 150;$temp_height = 180;$img_path = "test.jpg";$img_path2 = "test2.jpg";$im = @imagecreatefromjpeg($img_path);$temp_img=imagecreatetruecolor($temp_width,$temp_height);imagecopyresampled($temp_img,$im,0,0
Time of Update: 2016-07-25
require_once('../../lib/some_class.php');複製代碼這種寫法的缺點:它首先尋找指定的php包含路徑,然後尋找目前的目錄。因此會檢查過多重路徑。如果該指令碼被另一目錄的指令碼包含,它的基本目錄變成了另一指令碼所在的目錄。另外一個問題就是:當定時任務運行該指令碼,它的上級目錄可能就不是工作目錄了。因此,最佳選擇是使用絕對路徑,例如: define('ROOT' , '/var/www/project/');require_once(ROOT .
Time of Update: 2016-07-25
$a = getdate();printf('%s %d, %d',$a['month'],$a['mday'],$a['year']);?> 複製代碼 2,getdate()使用指定的timestamp $a = getdate(163727100);printf('%s %d, %d',$a['month'],$a['mday'],$a['year']);?>複製代碼3,getdate()擷取當前日期 getdate()擷取當前日期-bbs.it-home.org$date_array
Time of Update: 2016-07-25
require_once (dirname(__FILE__).'/config.inc.php');mysql_connect($cfg_db_host, $cfg_db_user, $cfg_db_password);mysql_select_db("$cfg_db_name");?>$body = '全球最大的中文搜尋引擎、最大的中文網站。2000年1月創立於北京中關村。
Time of Update: 2016-07-25
本文介紹下,用php定時產生靜態html首頁的一例代碼,有需要的朋友參考下。用php定時產生靜態頁面。代碼如下:start(); //開啟緩衝區include(”index.php”);$content = ob_get_contents(); //得到緩衝區的內容$content .= “n”; //加上調用更新程式的代碼file_put_contents(”index.html”,$content);if (!function_exists(”file_put_contents”)){
Time of Update: 2016-07-25
//chat.phpheader('cache-control: private');header('Content-Type: text/html; charset=utf-8');?>複製代碼儲存使用者提交的聊天內容簡易版本: $content = trim($_POST['content']);if ($content) {$fp = fopen('./chat.txt', 'a');fwrite($fp, $content .