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
$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
$mysql = new sqlstr("table1"); $mysql->set("name","value"); $mysql->set("name","1",true); echo $mysql->insertSql();複製代碼2,insert與update實現的php構造類 /*** Insert、Update語句的構造類* edit: bbs.it-home.org*/class sqlstr { private $param=array(); private
Time of Update: 2016-07-25
/* *功能:對URL進行編碼 *參數說明:$web_url 網站URL,不包含"http://",例如jbxue.com*/ function HashURL($url){ $SEED = "Mining PageRank is AGAINST GOOGLE'S TERMS OF SERVICE. Yes, I'm talking to you, scammer."; $Result = 0x01020345; for ($i=0; $i{ $Result ^= ord($SEED{$i%87
Time of Update: 2016-07-25
/*** 檢測php中的boolean布爾類型* edit: bbs.it-home.org*/var_dump((bool) ""); // bool(false)var_dump((bool) 1); // bool(true)var_dump((bool) -2); // bool(true)var_dump((bool) "foo"); // bool(true)var_dump((bool) 2.3e5); //
Time of Update: 2016-07-25
class Foo { function name_none_static(){ echo "My name is " . get_class() . ""; echo "My name is " . get_class($this) . ""; } } //類內部調用 $bar = new Foo(); $bar->name_none_static(); //類外部調用 echo "Its name is
Time of Update: 2016-07-25
在使用FCKedior或ueditor時,從word中粘貼過來的內容,會產生很多額外的標籤,本文分享一個清理這種多出的html代碼的函數,有需要的朋友參考下。說明:使用FCKedior或ueditor時,從word中粘貼過來的,會產生好多額外的標籤。本節分享一例代碼,用於清除word產生的html代碼。例子: '){mb_regex_encoding('UTF-8');$search = array('/‘/u', '/’/u', '/“/u',
Time of Update: 2016-07-25
$arr = array( array('id'=>1,'cid' => 1, 'country' => '中國','province'=>'湖南'), array('id'=>2,'cid' => 1, 'country' => '中國','province'=>'湖南'), array('id'=>3,'cid' => 3, 'country' => '日本','province'=>'名古屋'), array('id'=>4,'cid' => 3,
Time of Update: 2016-07-25
$database = "databaseName"; //資料庫名稱 $user = "root"; //資料庫使用者名稱 $pwd = "pwd"; //資料庫密碼 $replace ='pre_';//替換後的首碼 $seach = 'pre1_';//要替換的首碼 $db=mysql_connect("localhost","$user","$pwd") or die("串連資料庫失敗:".mysql_error()); //串連資料庫 $tables =
Time of Update: 2016-07-25
[root@jbxue /]# curl -I bbs.it-home.orgHTTP/1.1 200 OKServer: nginxDate: Tue, 20 Jul 2010 05:45:13 GMTContent-Type: text/html; charset=UTF-8Connection: keep-aliveVary: Accept-Encoding 複製代碼已隱藏了PHP版本。2、其它幾個PHP的基本安全設定: disable_functions =
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
$ip = "192.168.1.2";$ip_n = ip2long($ip);echo $ip_n; //得到 -1062731518?>複製代碼原因:IP轉換成的整型值太大超出了整型的範圍,所以變成負數。需要做如下的修改,修改為$ip_n = bindec(decbin(ip2long($ip)))即可得到無符號的整型數。例如: $ip = "192.168.1.2";$ip_n = bindec(decbin(ip2long($ip)));//by
Time of Update: 2016-07-25
/** PHP替換文章內鏈* by bbs.it-home.org*/function _base64_encode($t,$str) { return $t."\"".base64_encode($str)."\"";}function _base64_decode($t,$str) { return $t."\"".base64_decode($str)."\"";}function _keylinks($txt, $replacenum = '',$link_mode = 1) { /*
Time of Update: 2016-07-25
if($something){include("somefile");} 複製代碼但不管$something取何值,下面的代碼將把檔案somefile包含進檔案裡: if($something){require("somefile");} 複製代碼下面的這個有趣的例子充分說明了這兩個函數之間的不同。 $i = 1;while ($i require("somefile.$i");$i++;}
Time of Update: 2016-07-25
$ wget http://download.redis.io/releases/redis-2.6.16.tar.gz$ tar xzf redis-2.6.16.tar.gz$ cd redis-2.6.16$ make install 複製代碼2.配置 $ mkdir /etc/redis$ cp redis.conf /etc/redis/redis.conf $ gedit /etc/sysctl.conf$ sysctl -p
Time of Update: 2016-07-25
print number_format(100000.56 );?>複製代碼例2,number_format($n, $p, $t, $d) rounds $n to $p decimal places, using $t as the thousands separator and $d as the decimal separator. echo "Total charge is ", number_format($total, 2, ".", ","), "
Time of Update: 2016-07-25
//php 不同系統的換行 //不同系統之間換行的實現是不一樣的 //linux 與unix中用 /n //MAC 用 /r // bbs.it-home.org//window 為了體現與linux不同 則是 /r/n //所以在不同平台上 實現方法就不一樣 //php 有三種方法來解決 //1、使用str_replace 來替換換行 $str = str_replace(array("/r/n", "/r", "/n"), ""
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
/*** php自動產生關鍵字的內鏈* by bbs.it-home.org*/include_once(dirname(__file__)."/../db/DBViewSpot.php" );class InnerLink{ private static $spotUrlMap; /** * Generate view spots keywords link * * @param string $description * @param array
Time of Update: 2016-07-25
/*用處:加亮關鍵詞要求:備查文章內除html標籤外所有 符號分別用 < 和 > 替代 $rows['content']=str_replace(" $rows['content']=str_replace(">",">",$rows[content]);可能存在問題:效率不高 忘記了大小寫轉換問題$content:要加亮的備查文章$key:關鍵字site: bbs.it-home.org*/function highlight($content,$key) {