Time of Update: 2017-01-13
例1 代碼如下複製代碼 function get_user_browser() { if (empty($_SERVER['HTTP_USER_AGENT'])) { return ''; } $agent = $_SERVER['HTTP_USER_AGENT']; $browser = ''; $browser_ver = ''; if (preg_match('/MSIEs([^s|;]+
Time of Update: 2017-01-13
執行個體 代碼如下複製代碼 <?php /** * 把一個檔案夾裡的檔案全部轉碼 只能轉一次 否則全部變亂碼 * @param string $filename */ function iconv_file($filename,$input_encoding='gbk',$output_encoding='utf-8') { if(file_exists($filename)) { if(is_dir($filename)
Time of Update: 2017-01-13
例$str='這是字串我只替換ABC一次後面的ABC我不替換了,有沒有辦法實現。';把第一個abc替換成xyz,由於要替換的字串是固定的,很多人想到了用str_replace()函數,看看這個函數的使用是不是我們要的str_replace( mixed $search , mixed $replace , mixed $subject [, int &$count ] )不小心還真以為是我們想要的呢,最後那個參數是返回替換髮生的總次數,它是一個引用變數,而不是我要想要的指定它將替換幾次,
Time of Update: 2017-01-13
定義偽造使用者瀏覽器資訊HTTP_USER_AGENT 代碼如下複製代碼 $binfo =array('Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR 2.0.50727; InfoPath.2; AskTbPTV/5.17.0.25589; Alexa Toolbar)','Mozilla/5.0 (Windows NT 5.1; rv:22.0) Gecko/20100101
Time of Update: 2017-01-13
php header()頁面跳轉我把blog從http://www.你的網域名稱/blog遷移到http://www.111cn.net網域名稱下,當使用者訪問以前blog地址時,自動跳轉到當前blog的對應文章 代碼如下複製代碼 $url_this=strtolower('http://'.$_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"]);
Time of Update: 2017-01-13
核心代碼 代碼如下複製代碼 $t1 = microtime(true);// ... 執行代碼 ...$t2 = microtime(true);echo '耗時'.round($t2-$t1,3).'秒'; 上面為核心代碼下面我們詳細的來介紹一下 代碼如下複製代碼 <?php$start_time=microtime(true); //擷取程式開始執行的時間 echo "hello world!<br
Time of Update: 2017-01-13
我們先來看看microtime 和 memory_get_usage函數用法吧義和用法microtime() 函數返回當前 Unix 時間戳記和微秒數。文法microtime(get_as_float)參數 描述 get_as_float 如果給出了 get_as_float 參數並且其值等價於 TRUE,該函數將返回一個浮點數。例子 代碼如下複製代碼 <?phpecho(microtime());?> 輸出:0.25139300
Time of Update: 2017-01-13
代碼如下複製代碼 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html
Time of Update: 2017-01-13
本文介紹了使用jQuery、PHP和MySQL實作類別似360安全衛士防火牆開啟關閉的開關,可以將此功能應用在產品功能的開啟和關閉功能上。準備工作為了更好的示範本例,我們需要一個資料表,記錄需要的功能說明及開啟狀態,表結構如下:CREATE TABLE `pro` ( `id` int(11) NOT NULL auto_increment, `title` varchar(50) NOT NULL,
Time of Update: 2017-01-13
JS:設定 embed 高度和寬度可以改變 flash 的高度和寬度,從而擷取。 代碼如下複製代碼 <!DOCTYPE HTML><html><body><embed src="test550X400.swf" id="flash" width="550px" height="400px"/><script
Time of Update: 2017-01-13
/*array getimagesize ( string $filename [, array &$imageinfo ] )getimagesize()函數將確定任何給定的映像大小的檔案,並返回隨著檔案類型和高度/寬度的文本字串是在一個正常的HTML IMG標籤和相應的HTTP內容類型所使用的尺寸。The getimagesize() function will determine the size of any given image file and return the
Time of Update: 2017-01-13
function getServerName() { $ServerName = strtolower($_SERVER['SERVER_NAME']?$_SERVER['SERVER_NAME']:$_SERVER['HTTP_HOST']); if( strpos($ServerName,'http://') ) { return
Time of Update: 2017-01-13
function quickSort(&$data, $beg, $end) 02 { 03 if ($end > $beg) { 04 $piv = $data[$beg]; 05 $k = $beg + 1; 06 $r = $end; 07 while ($k < $r) { 08 if ($data[$k] < $piv) { 09 $k++; 10 } else
Time of Update: 2017-01-13
//這個是後台管理當中的分類列表頁//包含無限分類include ROOT.'include/tree.class.php';//聲明無限分類$tree = new tree();//設定緩衝目錄$tree->cDir = ROOT.'cache/class/';//讀入分類緩衝$tree->getCache('class');//擷取緩衝$rootArray = $tree->nodes;
Time of Update: 2017-01-13
PHP常用緩衝方式入門教程第一種,把需要緩衝的資料進行處理,形成PHP可以直接執行的檔案。在需要快取資料的時候,通過include方式引入,並使用。第二種,把需要的資料通過serialize函數序列化後直接儲存到檔案。在需要使用緩衝資料的時候,通過還原序列化讀入檔案內容並複製給需要的變數,然後使用。測試結果:通過測試我們發現,第二種也就是serialize快取資料的方式更加高效。(資料略去,最後提供了文章地址下載,大家可以自行測試)原因分析:include方式讀取緩衝的時候,PHP需要執行幾個過
Time of Update: 2017-01-13
php 批量產生縮圖代碼//建立目錄(目錄, [模式])function mkdirs($l1, $l2 = 0777){if(!is_dir($l1)){ //如果目錄不存在,遞迴建立 mkdirs(dirname($l1), $l2); return @mkdir($l1, $l2);}return true;}//儲存檔案(檔案, [內容])function savefile($l1, $l2=''){ if(function_
Time of Update: 2017-01-13
php fscokopen實現資料非同步呼叫代碼我們就可以使用fsockopen串連到本機伺服器,觸發指令碼執行,然後立即返回,不等待指令碼執行完成。 function triggerRequest($url,$post_data=array(),$cookie=array())…{ $method="GET";
Time of Update: 2017-01-13
php 面試題猴王演算法<?php/** filename: kingmonkey.php* author: luochuan wang* date: April 2nd, 2009* descript: an arithmetic to a program* program: 一群猴子排成一圈,按1,2,...,n依次編號。 然後從第1隻開始數,數到第m只,把它踢出圈, 從它後面再開始數,
Time of Update: 2017-01-13
<?php/** * 上傳檔案 * to : uploadBoroughThumb|borough|picture * to : 函數名|目錄分類|圖片類型 * */require('path.inc.php');$to = $_GET["to"];$action = $_GET['action'];if($action==""){ $action = "form";}
Time of Update: 2017-01-13
echo ccStrLen($str),'<hr>';echo ccStrLeft($str,3);function ccStrLeft($str,$len) #從左邊截取中英文混合字串{$ascLen=strlen($str); if($ascLen<=$len) return $str;$hasCC=ereg("[xA1-xFE]",$str);