Time of Update: 2016-07-29
如果直接調用mysql_connect會出現:Fatal error: Call to undefined function mysql_connect() 的錯誤 解決辦法, 找到zend studio php.ini所在的位置 我的zend studio安裝在D:\Program Files\ 所以php.ini所在位置為:D:\Program Files\Zend\Zend Studio for Eclipse -
Time of Update: 2016-07-29
使用 eAccelerator 加密PHP程式 複製代碼 代碼如下:# /usr/local/bin/encoder 執行後會看到簡單的使用說明: 複製代碼 代碼如下:Usage: encoder [options] source_file_name encoder [options] source_file_name... encoder [options] source_directory_name... Options: -s suffix encode files only with
Time of Update: 2016-07-29
這段時間在看《PHP和MySQL Web開發》一書看到str_replace講解,一段小提示寫到:可以為str_replace的三個都使用數組傳入,但講解比較簡單,於是決定自己的實驗一下該函數在各個參數傳入數組時的執行結果。 函數原型:mixed str_replace(mixed needle,mixed new_needle,mixed haystack[,int &count]);
Time of Update: 2016-07-29
一 前言 問題的存在從代碼層級上,也就是應用程式層次上考慮代碼安全的話(也就是不考慮底層的語言本身等問題的漏洞),指令碼安全問題就是函數和變數的問題。變數直接或者間接的接收使用者不安全的的輸入,由於php本身的特性,在php中更容易發現這種變數的混亂(很多php程式都用來定義以及初始化以及接收變數,可以直接在程式中使用$id這樣的變數,初始化完全由php的設定來完成,如果稍不注意,就可能導致變數的混亂從而導致攻擊)。
Time of Update: 2016-07-29
採集回來的圖片img標籤中,有好多javascript指令碼和無用的資訊,必需過替換自己想要的,比如alt。先看看要過濾的內容,我隨便複製出來: 複製代碼 代碼如下:sdfsdfsdfsfsdfsdfasdfsadfsdfsadfsdfsdf 要把上面替換成形如: 複製代碼 代碼如下: 其中src=”http://www.xxx.com/upimg/080330 /120D1232295023X0.gif” src=”http://www.xxx.com/upimg/080330 /120D12
Time of Update: 2016-07-29
1.驗證email: 複製代碼 代碼如下: if (ereg("/^[a-z]([a-z0-9]*[-_\.]?[a-z0-9]+)*@([a-z0-9]*[-_]?[a-z0-9]+)+[\.][a-z]{2,3}([\.][a-z]{2})?$/i; ",$email)){ echo “Your email address is correct!”;} else{ echo "Please try again!"; } ?> 匹配Email郵箱格式的Regex:
Time of Update: 2016-07-29
base64+gzinflate壓縮編碼(加密)過的檔案通常是以 壓縮編碼(加密)代碼:複製代碼 代碼如下:function encode_file_contents($filename) { $type=strtolower(substr(strrchr($filename,'.'),1)); if('php'==$type && is_file($filename) && is_writable($filename)){// 如果是PHP檔案 並且可寫 則進行壓縮編碼 $contents =
Time of Update: 2016-07-29
複製代碼 代碼如下:function bdir($dir,$typearr){ $ndir = scandir($dir); foreach ($ndir as $k => $v){ if ($v == '.' || $v == '..'){ continue; } if (filetype($dir.$v) == 'file'){ $arr = explode('.',$v); $type = end($arr); if (in_array($type,$typearr)){ echo
Time of Update: 2016-07-29
一、 在函數中,傳遞數組時使用 return 比使用 global 要高效,比如:function userloginfo($usertemp){ $detail=explode("|",$usertemp); return $detail; } $login=userloginfo($userdb); 比 function userloginfo($usertemp){ global $detail; $detail=explode("|",$usertemp); }
Time of Update: 2016-07-29
ob_start(); setcookie("username","宋岩賓",time()+3600); echo "the username is:".$HTTP_COOKIE_VARS["username"]."\n"; echo "the username is:".$_COOKIE["username"]."\n"; print_r($_COOKIE); ?> Warning: Cannot modify header information - headers already
Time of Update: 2016-07-29
1.在SQLyog下輸入下面代碼,全部執行 SET character_set_client = utf8; SET character_set_results = gb2312; SET character_set_connection = utf8; 如果上邊的不行,還可以改成Gbk。總以根據你的資料的文字編碼改成相應的編碼類別型就ok了。給出Gbk的代碼: SET character_set_client = gbK; SET character_set_results = gbK;
Time of Update: 2016-07-29
在你的程式初始化時使用如下代碼: 複製代碼 代碼如下:$Php2Html_FileUrl = $_SERVER["REQUEST_URI"]; $Php2Html_UrlString = str_replace("/", "", strrchr($Php2Html_FileUrl, "/")); $Php2Html_UrlQueryStrList = explode("@", $Php2Html_UrlString); foreach($Php2Html_UrlQueryStrList as $
Time of Update: 2016-07-29
關於DISCUZ不用通行證登陸得內容介紹 DISCUZ是中國最常用的論壇,雖然他本身有通行證給大家串連,但實際上使用者的統一還是很不好,經常要建立兩個使用者表,第一不利於註冊和管理,第二浪費資料庫。 最近做一個項目也是使用的DISCUZ,所以研究了一下DISCUZ的登陸,基本完成了同步登陸。大家如果有興趣可以研究一下。
Time of Update: 2016-07-29
基本原形為: {section name = name loop = $varName[, start = $start, step = $step, max = $max, show = true]} name: section的名稱,不用加$ $loop: 要迴圈的變數,在程式中要使用assign對這個變數進行操作。 $start: 開始迴圈的下標,迴圈下標預設由0開始 $step: 每次迴圈時下標的增數 $max: 最大迴圈下標 $show: boolean類型,決定是否對這個塊進行顯示,
Time of Update: 2016-07-29
for ($i=10; $i>0; $i--) { echo $i; flush(); sleep(1); } ?> 按照php手冊裡的說法 該函數將當前為止程式的所有輸出發送到使用者的瀏覽器。 上面的這段代碼,應該隔一秒鐘輸出一次$i。但是實際中卻不一定是這樣。有可能是等了10秒鐘後,所有的輸出同時呈現出來。 好,我們來改一下這段代碼,改成 ob_end_clean();//修改部分 for ($i=10; $i>0; $i--) { echo $i; flush(); sleep(1); }
Time of Update: 2016-07-29
友好URL的實現(吐血推薦) 大家經常看到別的站的URL是這樣的吧? http://www.xxx.com/module/show/action/list/page/7 或者 http://xx.com/module/show/action/show/id/8.shtml 帶副檔名的 或者 http://xx.com/module/show/action/show/id/8?word=ss&age=11 這樣的吧 今天我就是公布下這種方法的實現,並獨立出最簡單的代碼
Time of Update: 2016-07-29
複製代碼 代碼如下:/** * 顯示樣式2 */ function multi($mpurl,$page = 10) { $multipage = ''; $mpurl .= strpos($mpurl, '?') ? '&' : '?'; $realpages = 1; if($this->infocount > $this->items) { $offset = 2; $realpages = @ceil($this->infocount / $this->items); $pages =
Time of Update: 2016-07-29
function set_4pixel($r, $g, $b, $x, $y) { global $sx, $sy, $pixels; $ofs = 3 * ($sx * $y + $x); $pixels[$ofs] = chr($r); $pixels[$ofs + 1] = chr($g); $pixels[$ofs + 2] = chr($b); $pixels[$ofs + 3] = chr($r); $pixels[$ofs + 4] = chr($g); $pixels[$ofs
Time of Update: 2016-07-29
/** * 功能:產生縮圖 * 作者:phpox * 日期:Thu May 17 09:57:05 CST 2007 */ class CreatMiniature { //公開變數 var $srcFile=""; //原圖 var $echoType; //輸出圖片類型,link--不儲存為檔案;file--儲存為檔案 var $im=""; //臨時變數 var $srcW=""; //原圖寬 var $srcH=""; //原圖高 //設定變數及初始化 function SetVar($
Time of Update: 2016-07-29
session_start(); session_register("login_check_number"); //昨晚看到了chianren上的驗證碼效果,就考慮了一下,用PHP的GD庫完成了類似功能 //先成生背景,再把產生的驗證碼放上去 $img_height=120; //先定義圖片的長、寬 $img_width=40; if($HTTP_GET_VARS["act"]== "init"){ //srand(microtime() *