Time of Update: 2017-01-19
第1種寫法:複製代碼 代碼如下:<?phpstr_replace("n", '', $str); ?>第2種寫法:複製代碼 代碼如下:<?phpstr_replace("rn", '', $str); ?>第3種寫法:複製代碼 代碼如下:<?phppreg_replace("/s/", '', $str); ?>下面進行相關說明:首先說說 n,r,tn
Time of Update: 2017-01-19
複製代碼 代碼如下:// local file that should be send to the client$local_file = 'test-file.zip';// filename that the user gets as default$download_file = 'your-download-name.zip';// set the download rate limit (=> 20,5 kb/s)$download_rate =
Time of Update: 2017-01-19
HTML首先在head部分載入raphael.js庫檔案和chinamapPath.js路徑資訊檔,本文不重複寫下,唯一不同的地方是需要在body中加一個div#tip,用來展示地圖資訊的提示框。複製代碼 代碼如下:<div id="map"></div> <div id="tip"></div>
Time of Update: 2017-01-19
不多說,代碼送上:複製代碼 代碼如下:<?phpfunction Pinyin($_String, $_Code='gb2312'){$_DataKey =
Time of Update: 2017-01-19
複製代碼 代碼如下:<?php$srcdir='./image/';$prefix="pic11_";$dst="image";$imagedir=scandir($srcdir);array_shift($imagedir);array_shift($imagedir);$width=0;$height=0;foreach ($imagedir as $key => $value)
Time of Update: 2017-01-19
靚點:1、多對多交叉情境分配;2、php新特性-閉包使用、批處理函數array_walk/array_flip使用;3、位元運算&使用案例;使用情境:1、常見增刪改查(2的N次方值入庫);2、認證、第三方帳號綁定、多分類選擇;複製代碼 代碼如下:<?phpclass s_allow{//聲明使用情境,任務清單public $scene,$case_list=array();//聲明指定使用者角色、允許值、允許清單public
Time of Update: 2017-01-19
百度翻譯API的PHP代碼,測試可以實現,不過英譯中可能需要轉換編碼。複製代碼 代碼如下:<?phpfunction language($value,$from="auto",$to="auto"){ $value_code=urlencode($value); #首先對要翻譯的文字進行 urlencode 處理 $appid="YourApiKey"; #您註冊的API Key $languageurl =
Time of Update: 2017-01-19
複製代碼 代碼如下:<?phpclass session_handler { protected $maxlifetime = null; protected $dbHandle = null; public $config = null; public static function init($args) { return new self($args); } public function
Time of Update: 2017-01-19
複製代碼 代碼如下:<?php//禁止錯誤輸出error_reporting(0);//設定錯誤處理器set_error_handler('errorHandler');register_shutdown_function('fatalErrorHandler');class Test{public function index(){//這裡發生一個警告錯誤,出發errorHandler echo $undefinedVarible;}}function
Time of Update: 2017-01-19
複製代碼 代碼如下:<?phpfunction custom(){}class custom{ public function index(){ } }print_r(get_define_position('custom')); /** * / * @param string $name 函數名或者類名 * @return
Time of Update: 2017-01-19
以數字開頭的重複資料如:複製代碼 代碼如下:Array ( [0] => 100 [k1] => 100 [1] => 2123 [k2] => 2123 ) 該方法可以將以數字為key的值去掉,先將數組按照key倒序排序,然後用array_unique的方法將重複的值去掉。不能適用於下面的情況:不同的key值存在相同的value的情況複製代碼 代碼如下:function array_unique_value($arr =
Time of Update: 2017-01-19
分享一例php分頁函數代碼,用此函數實現分頁代碼很不錯。代碼,php分頁函數。複製代碼 代碼如下:<?php/** Created on 2011-07-28* Author : LKK , http://lianq.net* 使用方法:require_once('mypage.php');$result=mysql_query("select * from mytable",
Time of Update: 2017-01-19
複製代碼 代碼如下:<?php class='pingjiaF' frameborder='0' src='http://www.jb51.net' scrolling='no'> 對數組排序 usort() 函數使用使用者自訂的函數對數組排序。 */ function cmp($a, $b) //使用者自訂回呼函數 { if($a==$b) //如果兩個參數相等 {
Time of Update: 2017-01-19
學校的新聞系統要求有些新聞只開放校內ip瀏覽,於是重寫了一個代碼來實現此功能,實現後的結果是,只要把允許訪問的ip列入ip.txt這個檔案中即可,同時支援c類ip,例如:ip.txt192.168211.67.188211.67.191.25代碼如下:複製代碼 代碼如下:/** ip地址黑名單、白名單* 判斷訪客地址的ip是否在ip.txt中,支援c類ip* By xhat*/$ip = $_SERVER['REMOTE_ADDR'];$ipArray = preg_replace("#rn?|
Time of Update: 2017-01-19
複製代碼 代碼如下:<?php /** * listdir */ header("content-type:text/html;charset=utf-8"); $dirname = "./final/factapplication"; function
Time of Update: 2017-01-19
1,自訂函數2,spl_autoload_register()複製代碼 代碼如下:liuyuan@ebuinfo:/var/www/phpgcs/php_autoload$ ll ./*-rw-rw-r-- 1 liuyuan liuyuan 800 Feb 19 11:39 ./func_autoload.php-rw-rw-r-- 1 liuyuan liuyuan 906 Feb 19 11:28 ./spl_autoload.php./include:total
Time of Update: 2017-01-19
sql有許多對資料庫操作的語句。但是常見和比較需要的是這麼幾個語句 。SELECT 語句用於從資料庫中選取資料。 那麼我們先來介紹第一種 SELECT語句語句1:SELECT * FROM table_name解說:意思就是讀取整個表table_name裡面的資料顯示出來語句1:SELECT * FROM table_name Where x = 1解說:意思就是讀取表table_name裡面鍵名為:x 值為:1的 資料顯示出來 Select 查詢語句的例子複製代碼
Time of Update: 2017-01-19
例如:現在有1,2,3。3頁。希望使用者一開始訪問第一頁,然後點“下一步”就看到“第二頁”,然後在進入“第三頁”之前,使用者不能後退。就讓1和2作為同一頁。留個標記在session裡,這樣:1and2.php複製代碼 代碼如下:<?phpsession_start();if (isset($_GET['p2'])) { $_SESSION['enteredPage2'] = true;}if (isset($_SESSION['enteredPage2'])) {
Time of Update: 2017-01-19
PHP刪除數組元素的具體方法:1.用unset()方法:複製代碼 代碼如下:<?php$a=array("red", "green", "blue", "yellow"); count($a); //得到4 unset($a[1]); //刪除第二個元素 count($a); //得到3 echo $a[2];
Time of Update: 2017-01-19
複製代碼 代碼如下:<?phpclass AESMcrypt { public $iv = null; public $key = null; public $bit = 128; private $cipher; public function __construct($bit, $key, $iv, $mode) { if(empty($bit) || empty($key) || empty($iv) ||