Time of Update: 2016-07-25
//當為0時,關閉計劃任務return 1;?>複製代碼2,jbxue.php ignore_user_abort();//關掉瀏覽器,PHP指令碼也可以繼續執行.set_time_limit(0);// 通過set_time_limit(0)可以讓程式無限制的執行下去$interval=60*3;// 每隔3分鐘運行$ii=0;do{$run = include 'jhrw.conf.php';if(!$run) { file_put_contents("tasktest.txt","=
Time of Update: 2016-07-25
/*** 一般檔案安全下載* edit bbs.it-home.org*/ $durl = 'file/phpcms2008_o2abf32efj883c91a.iso'; $filename = 'phpcms2008_o2abf32efj883c91a.iso'; $file = @fopen($durl, 'r'); header("Content-Type: application/octet-stream"); header(
Time of Update: 2016-07-25
//所謂斷字 (word break),即一個單詞可在轉行時斷開的地方。這一函數將在斷字處截斷字串。// Please acknowledge use of this code by including this header.function myTruncate($string, $limit, $break=".", $pad="...") {// return with no change if string is shorter than
Time of Update: 2016-07-25
/*** 遍曆並解析xml檔案為一個數組* edit bbs.it-home.org*/public function parseXML($menus){ $result = array(); foreach($menus as $menu){ $tmparr = array(); //處理空文本節點方式A if( $menu->nodeName !='#text'){ // 檢索子項目時跳躍過文本節點 - 處理空文本節點方式B
Time of Update: 2016-07-25
/*** 產生gif動畫的代碼* edit bbs.it-home.org*/class GifMerge {var $ver = '1.1';var $dly = 50;var $mod = 'C_FILE';var $first = true;var $use_loop = false;var $transparent = false;var $use_global_in = false;var $x = 0;var $y = 0;var $ch = 0;var $fin = 0;var $
Time of Update: 2016-07-25
nginx中文手冊下載複製代碼2,檔案get.php,內容如下: /*** php實現檔案下載* edit bbs.it-home.org*/if (!isset(GET["file"]) || !isset(GET["type"])) { print "no file selsect"; exit(); }$file = GET["file"].".".GET["type"]; if (@$fp = fopen($file,'r')){ header ("Content-type:
Time of Update: 2016-07-25
exec(""/bin/ls -l"");exec(""/bin/ls -l"", $res);#$res是一個資料,每個元素代表結果的一行exec(""/bin/ls -l"", $res, $rc);#$rc的值是命令/bin/ls -l的狀態代碼。成功的情況下通常是0?>複製代碼passthru()原型:void passthru (string command [, int
Time of Update: 2016-07-25
/*** 驗證碼類* edit bbs.it-home.org*/class ValidationCode {private $width;private $height;private $codeNum;private $image; //映像資源private $disturbColorNum;private $checkCode;function __construct($width=80, $height=20,
Time of Update: 2016-07-25
/** filename:mysql資料庫連接類* edit bbs.it-home.org*/class mysql{private $db_host; //資料庫主機private $db_user; //資料庫使用者名稱private $db_pwd; //資料庫使用者名稱密碼private $db_database; //資料庫名private $conn; //資料庫連接標識;private $result; //執行query命令的結果資源標識private $sql;
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
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
echo implode(",", array('lastname', 'email', 'phone'));//數組轉成字串複製代碼explode: print_r(explode(",", 'lastname,email,phone'));//字串轉成數組複製代碼split: print_r(split("[/.-]","2008-9.12"));//以/或.或-任一符號切成數組複製代碼str_split: print_r(str_split("Hello
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
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
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
ob_start();echo '1';ob_flush();//輸出php緩衝並重新整理echo '2';ob_flush();//輸出php緩衝並重新整理$cc = ob_get_contents();ob_end_clean();var_dump($cc);?>複製代碼輸出:12string(0) ""測試2: ob_start();echo '1';flush(); //輸出apache緩衝並重新整理echo '2';flush(); //輸出apache緩衝並重新整理$
Time of Update: 2016-07-25
$unsafe_variable = $_POST['user_input'];mysql_query("INSERT INTO table (column) VALUES ('" . $unsafe_variable . "')");複製代碼這是因為使用者可以輸入類似VALUE“); DROP TABLE表; - ,使查詢變成: INSERT INTO table (column) VALUES('VALUE'); DROP TABLE