Time of Update: 2017-01-13
然而今天我卻發現這個__autoload魔術方法或者你願意稱他為魔術函數,太專一了。當他載入需要包含的類檔案時,甚至不管類檔案中定義類之外的其它聲明。開始回放這個機制。首先我們在建立一個Test.class.php檔案,鍵入如下內容 代碼如下複製代碼 $publicPara='中共十七大啥時候召開的?';class Test{ public function __construct(){ global $publicPara;
Time of Update: 2017-01-13
代碼如下複製代碼 /** * 獲得使用者的真實IP地址 * * @return string */function real_ip(){ static $realip = NULL; if ($realip !== NULL){ return $realip;&
Time of Update: 2017-01-13
用的是表頭方式下載 代碼如下複製代碼 Header( "Content-type: application/octet-stream "); Header( "Accept-Ranges: bytes "); Header( "Accept-Length: ".filesize($file_dir
Time of Update: 2017-01-13
代碼如下複製代碼 <?php function foreachDir($path){ $handle=opendir($path); if($handle){ while (false !== ($file = readdir($handle))) { if($file!="." && $file!='..'){ if(is_dir($path.$file)){ echo
Time of Update: 2017-01-13
字串的替換技術可以通過以下兩個常用函數實現:str_ireplace()函數和substr_replace()函數str_ireplace()函數使用新的子字串替換原始字串中被指定要替換的字串,文法:mixed str_ireplace(mixed search,mixed replace,mixed
Time of Update: 2017-01-13
GB2312編碼: 代碼如下複製代碼 function unescape($str) { $str = rawurldecode($str); preg_match_all("/%u.{4}|&#x.{4};|&#d+;|.+/U",$str,$r); $ar = $r[0]; foreach($ar as $k=>$v) { if(substr($v,0,2) == "%u") $ar[$k] = iconv(&
Time of Update: 2017-01-13
代碼如下複製代碼 function smssubstr($string, $length) { if(strlen($string) <= $length) { return $string; } $strcut = ''; for($i = 0; $i < $length; $i++) { $strcut .= ord($string[$i]) > 127 ?
Time of Update: 2017-01-13
代碼如下複製代碼 ////////////////////無限分類的資料庫設計及範例//////////////mysql> create database db_kind;Query OK, 1 row affectedmysql> use db_kind;Database changedmysql> create table tb_kind(-> id int not null auto_increment primary key,-
Time of Update: 2017-01-13
代碼如下複製代碼 <?php $s = rand(100,200); $pi=pi(); $r=sqrt($s/$pi); $qz1=round($r); //四捨五入取整 $qz2=ceil($r); //進一法取整 $qz3=floor($r); //捨去法取整
Time of Update: 2017-01-13
代碼如下複製代碼 <?phpclass Shopcar {//商品列表public $productList=array();/** * * @param unknown_type $product 傳進來的商品 * @return true 購物車裡面沒有該商品 */public function
Time of Update: 2017-01-13
本例我們使用Mysql資料庫,建立一張user表,表結構如下: 代碼如下複製代碼 CREATE TABLE `user` ( `id` int(11) NOT NULL auto_increment, `username` varchar(30) NOT NULL COMMENT '使用者名稱', `password` varchar(32) NOT NULL COMMENT '密碼', `login_time`
Time of Update: 2017-01-13
代碼如下複製代碼 //將數字轉換為漢字,比如1210轉換為一千二百一十 $num = "842105580";//九位元 function del0($num) //去掉數欄位前面的0 { return "".intval($num); } function n2c($x) //單個數字變漢字 { $arr_n = array("零","一","二","三",
Time of Update: 2017-01-13
代碼如下複製代碼 <?phpfunction wfopen($url,$post='',$cookie='',$timeout=15) { $matches = parse_url($url); $out = "POST {$matches['path']}
Time of Update: 2017-01-13
代碼如下複製代碼 function tranTime($time) { $rtime = date("m-d H:i",$time); $htime = date("H:i",$time); $time = time() - $time; &
Time of Update: 2017-01-13
代碼如下複製代碼 <?php /** File: CurrencyConverter.php* Author: Simon Jarvis* Copyright: 2005 Simon Jarvis* Date: 10/12/05* Link: http://www.white-hat-web-design.co.uk/articles/php-currency-conversion.php ** This program is free
Time of Update: 2017-01-13
代碼如下複製代碼 <html><head><title>Login</title><meta http-equiv="Content-Type" content="text/html; charset=gb2312"></head> <body><form name="form1" method="post"
Time of Update: 2017-01-13
代碼如下複製代碼 html<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta
Time of Update: 2017-01-13
原理是如果資料通過了上邊的兩次驗證,說明資料是合法有效資料。這時候我們把提交的資料串接為一個字串,並用MD5加密後得到一個MD5的值,接著我們把這個值通過Cookie放進用戶端,當使用者下一次提交表單的時候我們就重新操作這一步,並且讀出Cookie中的MD5值,進行比較,如果相同就可斷定使用者提交兩次提交的表單是相同的,否則替換這個Cookie! 代碼如下複製代碼 <?php//……$lasthash =
Time of Update: 2017-01-13
行刪除檔案夾的操作時,必須首先確保您有這個許可權! 代碼如下複製代碼 <?php // 說明: 刪除非空目錄的解決方案function removeDir($dirName) { if(! is_dir($dirName)) { return false; }
Time of Update: 2017-01-13
如何使用php做站內搜尋並高亮顯示關鍵字? 代碼如下複製代碼 <?php require_once 'sqlTools.class.php';//封裝類,可執行dql、dml語句 $info=$_POST['info'];