Time of Update: 2016-07-25
/** 例1,文字檔記錄資料* edit bbs.it-home.org*/$counter=1;if(file_exists("mycounter.txt")){$fp=fopen("mycounter.txt","r");$counter=fgets($fp,9);$counter++;fclose($fp);}$fp=fopen("mycounter.txt","w");fputs($fp,$counter);fclose($fp);echo "您是第".$counter."次訪問本頁面!
Time of Update: 2016-07-25
//可逆的加密函數function authcode($string, $operation = 'DECODE', $key = '', $expiry = 0) {$ckey_length = 4; // 隨機密鑰長度 取值 0-32;// 加入隨機密鑰,可以令密文無任何規律,即便是原文和密鑰完全相同,加密結果也會每次不同,增大破解難度。// 取值越大,密文變動規律越大,密文變化 = 16 的 $ckey_length 次方// 當此值為 0 時,則不產生隨機密鑰$key =
Time of Update: 2016-07-25
/** * php 驗證碼 可自訂大小 * edit bbs.it-home.org*/function vCode($num=4,$size=20, $width=0,$height=0){!$width && $width = $num*$size*4/5+5;!$height && $height = $size + 10;// 去掉了 0 1 O l 等$str =
Time of Update: 2016-07-25
Header("Location: http://bbs.it-home.org";);exit;//在每個重新導向之後都要加上“exit",避免發生錯誤後,繼續執行。?>複製代碼2, header("refresh:2;url=http://bbs.it-home.org");echo "正在載入,請稍等...三秒後自動跳轉至程式員之家...";?>複製代碼例二:禁止頁面在IE中緩衝使瀏覽者每次都能得到最新的內容,而不是 Proxy 或 cache 中的資料: header(
Time of Update: 2016-07-25
$_COOKIE["counter"]?($c=$_COOKIE["counter"]+1):($c=1);setCookie("counter",$c,time()+60);echo "歡迎您第"."".$c."次訪問cookie";//by bbs.it-home.org?>複製代碼下面是有關這個例子的代碼說明,供大家參考。以上代碼中,首先,瀏覽器請求一個資源(這個php頁面),發送下面的HTTP包頭內容到伺服器: GET http://localhost/index.php HTTP/1.
Time of Update: 2016-07-25
//即使Client斷開(如關掉瀏覽器),PHP指令碼也可以繼續執行.ignore_user_abort();// 執行時間為無限制,php預設的執行時間是30秒,通過set_time_limit(0)可以讓程式無限制的執行下去set_time_limit(0);// 每隔5分鐘運行$interval=60*5;do{$url = “http://bbs.it-home.org”;$ch = curl_init();curl_setopt($ch, CURLOPT_URL,
Time of Update: 2016-07-25
本文介紹下,在php編程中,操作JSON時出現中文亂碼的解決方案,有需要的朋友,不妨參考下。在使用Ajax技術與PHP後台互動時,中文亂碼是常有的事,JSON作為與XML類似的資料交換格式,在PHP用來進行互動時也會出現中文 亂碼的情況。解決PHP JSON中文亂碼的方法與PHP
Time of Update: 2016-07-25
// 加密資料並寫到cookie裡$cookie_data = $this -> encrypt("nowamagic", $data);$cookie = array('name' => '$data','value' => $cookie_data,'expire' => $user_expire,'domain' => '','path' => '/','prefix' => '');$this->input->set_cookie($cookie);// 加密public
Time of Update: 2016-07-25
function test($a, $b){echo '測試一:'.$a.$b;}//調用test方法,array("asp", 'php')對應相應的參數call_user_func_array('test', array("asp", 'php'));?>複製代碼二、通過類調用類中的方法 class test2{function phpSay($a, $b){echo '測試二:'.$a.$b;}}$o = new
Time of Update: 2016-07-25
query_cache_size=32M# The number of open tables for all threads. Increasing this value # increases the number of file descriptors that mysqld requires. # Therefore you have to make sure to set the amount of open files # allowed to at least 4096 in
Time of Update: 2016-07-25
void ob_start(void);?>複製代碼告訴PHP處理器把所有的輸出重新導向到一個內部的緩衝(buffer)中。在調用ob_start之前,沒有輸出會被送到瀏覽器去。 string ob_get_contents(void);?>複製代碼該函數將“輸出緩衝”(output buffer)以字串的形式返回。你可以調用該函數把積累下來的輸出送到瀏覽器中。(僅在把buffering功能關閉之後!!) int ob_get_length(void);?>複製代碼返回緩衝中的字串的長度。
Time of Update: 2016-07-25
function fun() { echo 'fun'; } $a = 'fun'; $a();?> 複製代碼上面的$a變數就是fun()函數,調用$a()和調用fun()是一樣的。另一種方法。調用PHP中的函數:mixed call_user_func ( callback $function [, mixed $parameter [, mixed $...]] )mixed call_user_func_array ( callback
Time of Update: 2016-07-25
//方法1echo date("Y-m-d h:i:s"); //方法2date_default_timezone_set('Asia/Chongqing'); //系統時間差8小時問題$now = getdate(time());$cur_wday=$now['wday'];$date = date("Y-m-d H:i:s $cweekday[$cur_wday]");echo $date;//by bbs.it-home.org?> 複製代碼date函數中字母代表的含義:a -
Time of Update: 2016-07-25
zlib.output_compression = Off;zlib.output_compression_level = -1 複製代碼修改為: zlib.output_compression = Onzlib.output_compression_level = 6複製代碼其中,zlib.output_compression_level = 6 的數字6是壓縮比例二、開啟apache 設定檔httpd.conf,配置裝載deflate_module,找到#LoadModule
Time of Update: 2016-07-25
CREATE TABLE ccol(id integer not null auto_increment, #記錄的IDip char(15) not null, #訪問者的IP地址dtstamp datetime not null, #最後訪問時間uri char(255), #訪問者請求的URIprimary key (id));複製代碼然後,編寫統計用的php代碼 /*檔案:ccol.php目的:統計同時線上瀏覽的人數edit: bbs.it-home.org*/$duration=180
Time of Update: 2016-07-25
本文介紹下,如何通過配置php.ini檔案來實現屏蔽php錯誤的方法,供大家學習參考。在php的設定檔 php.ini中配置相關內容,實現屏蔽php中相關錯誤。如下所示:; Error handling and logging ;; 出錯控制和登記 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 錯誤報表是按位的。或者將數字加起來得到想要的錯誤報表等級。; E_ALL - 所有的錯誤和警告; E_ERROR - 致命性運行時錯; E_WARNING - 運行時警告(非致命性錯)
Time of Update: 2016-07-25
if (count($array) != count(array_unique($array))) { echo '該數組有重複值'; } ?>複製代碼PHP去除重複的數組資料 $input = array("a" => "green","", "red","b" => "green", "","blue", "red","c" => "witer","hello","witer");//$result = array_unique($input); //去除重複元素$result
Time of Update: 2016-07-25
output_buffering = Offoutput_handler =zlib.output_compression = On 複製代碼即可實現為全站的php檔案啟用gzip加速。對於html檔案,可以通過配置.htaccess檔案,由php來處理html請求(會加重伺服器負擔,建議在nginx或apache上做gzip處理): AddHandler x-httpd-php .html
Time of Update: 2016-07-25
extension_dir = "C:/ipaddr/php/extensions/" 複製代碼(注意,建議寫全地址,並且後面加上/,很多時候是因為這裡設定不對,才導致無法載入其它模組的dll的)再開啟: extension=php_gd2.dll
Time of Update: 2016-07-25
unserialize(iconv('gbk','utf-8',serialize($array))); 複製代碼結果是空白的。藉助var_export函數,最終函數如下: function array_iconv($in_charset,$out_charset,$arr){ return eval('return '.iconv($in_charset,$out_charset,var_export($arr,true).';'));}