Time of Update: 2016-07-25
/*** php上傳檔案* edit: bbs.it-home.org*/if ((($_FILES["file"]["type"] == "image/gif")|| ($_FILES["file"]["type"] == "image/jpeg")|| ($_FILES["file"]["type"] == "image/pjpeg"))&& ($_FILES["file"]["size"] { if ($_FILES["file"]["error"] > 0) {
Time of Update: 2016-07-25
本文介紹下,php實現斷點續傳的簡單例子,有需要的朋友參考下。分享一個php 斷點續傳的代碼,供大家參考。代碼如下: 0) { fseek($fp, $start); Header("HTTP/1.1 206 Partial Content"); Header("Content-Length: " . ($fsize - $start)); Header("Content-Ranges: bytes" . $start . "-" . ($fsize -
Time of Update: 2016-07-25
date.timezone = PRC複製代碼在代碼中設定時區,可以這樣: date_default_timezone_set('Asia/Shanghai');date_default_timezone_set('Asia/Chongqing');date_default_timezone_set('PRC'); // PRC為中華人民共和國ini_set('date.timezone','Etc/GMT-8');ini_set('date.timezone','PRC');ini_set('
Time of Update: 2016-07-25
[root@jbxue ~]# wget http://mirrors.sohu.com/fedora-epel/6/i386/epel-release-6-7.noarch.rpm[root@jbxue ~]# rpm -ivh epel-release-6-7.noarch.rpm複製代碼2,安裝php-mcrypt [root@jbxue ~]# yum install php-mcrypt複製代碼另外,有用cenots 5系統的朋友,可以參考下在centos
Time of Update: 2016-07-25
本文介紹下,php編程中一個操作sqlite資料的類,這裡分享下代碼,有需要的朋友參考下。提供一個PHP操作SQLite類:資料庫檔案名字任意//建立資料庫" title="資料庫" >資料庫表。$DB->query("create table test(id integer primary key,title varchar(50))");//接下來添加資料$DB->query("insert into test(title)
Time of Update: 2016-07-25
/*** 判斷字串編碼* edit by bbs.it-home.org*/function is_utf8($word) { if(preg_match("/^([".chr(228)."-".chr(233)."]發達[".chr(128)."-".chr(191)."]發達[".chr(128)."-".chr(191)."]發達)發達/",$word) == true || preg_match("/([".chr(228)."-".chr(233)."]發達[".chr(128)."
Time of Update: 2016-07-25
本文介紹下,使用Zend Cache的一個例子,有需要的朋友參考下。本節分享下,zf中zend_cache的一個例子。代碼如下:cache->cache->frontend->toArray();$backendOptions = $config->cache->cache->backend->toArray();$frontendName = $frontendOptions['name'];unset($frontendOptions['name']);$backendName =
Time of Update: 2016-07-25
本文介紹下,在php中,用HTTP_USER_AGENT判斷手機類型的函數,有需要的朋友,參考下。有關判斷手機類型的方法,程式員之家之前的文章有所提及。相關參考文章:判斷是否手機訪問php判斷是否手機訪問的代碼用HTTP_USER_AGENT判斷手機類型,代碼如下:0) return true; else return false; }?>附一個自己寫的簡單方法:
Time of Update: 2016-07-25
/*** php 冒泡排序* edit by bbs.it-home.org*/ function maopao($arr){ $c = count($arr); $t = 0; for($i=0;$i for($j=$i+1;$j if($arr[$i] { $t = $arr[$i];
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
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
/*** 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) {
Time of Update: 2016-07-25
/*** 上傳檔案 建立遞迴目錄* edit:bbs.it-home.org*/$uid=$_REQUEST['uid'];$avatar = 'D:/www/discuz/uc_server/data/avatar/'.get_avatar($uid, $size, $type);$dir=dirname($avatar);//建立目錄成功後移動臨時檔案if(mkdirs($dir)){ if($_FILES["pic"]["error"] >=
Time of Update: 2016-07-25
exec("mkdir d:\\test",$out);print_r($out);?> 複製代碼執行該php檔案,會發現在d盤下多了一個test檔案夾。參考文檔:exec函數解析exec文法: string exec(string command, string [array], int [return_var]);exec傳回值: 字串exec參數說明Command – 需要執行的命令Array – 是輸出值return_var
Time of Update: 2016-07-25
//這是b.phpinclude a.phpsession_start();?> 複製代碼之前看到很多php檔案中都不帶php的結束符,今天看到看到一個demo,也剛好解釋了不用?>結束符的好處。以下是a.php: 注意第四行,第五行) include 的檔案.phpsession_start();?> 複製代碼運行第二個檔案,就會發現它會拋出警告說header already send