Time of Update: 2016-07-25
/** 目錄處理函數*/function dir_path($path) {$path = str_replace('\\', '/', $path);if (substr($path, -1) != '/') $path = $path . '/';return $path;}/*** 列出目錄下的所有檔案** @param str $path 目錄* @param str $exts 尾碼* @param array $list 路徑數組* @return array
Time of Update: 2016-07-25
$filename = '/path/to/foo.txt';if (file_exists($filename)) {echo "The file $filename exists";} else {echo "The file $filename does not exist";}?>複製代碼如果檔案存在,執行該 PHP 檔案的顯示結果是:The file C:blablaphphello.txt exists.如果檔案不存在,執行該 PHP 檔案的顯示結果是:The file
Time of Update: 2016-07-25
因為mb_substr、mb_strlen太過低效,故而採用了此段代碼。 非原創,主要原理是根據UTF-8的編碼特點 0xxxxxxx 110xxxxx 10xxxxxx 1110xxxx 10xxxxxx 10xxxxxx 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx 111110xx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx 1111110x 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx 10
Time of Update: 2016-07-25
效率對比(12688個字元,替換1次): str_replace: 0.109937906265秒 strtr: 0.0306839942932秒 替換結果對比 比如:「張三」、「張三丰」、「張三丰田」 均為違禁詞 (為何會有這樣的區分?請參見 「法X」、「法Xgong」) 原文:「我今天開著張三丰田去上班 」 strtr:「我今天開著****去上班 」(四個詞均替換為了*) str_replace:「我今天開著**豐田去上班 」(
Time of Update: 2016-07-25
/** * Lunar calendar 博大精深的農曆 * 未經處理資料和演算法思路來自 S&S Lab http://www.focus-2000.com 可惜網站好像關了 */ /* 農曆每月的天數。 每個元素為一年。每個元素中的資料為: [0]是閏月在哪個月,0為無閏月; [1]到[13]是每年12或13個月的每月天數; [14]是當年的天幹次序, [15]是當年的地支次序 */
Time of Update: 2016-07-25
PHP實現的LZW壓縮演算法 /** * @link http://code.google.com/p/php-lzw/* @author Jakub Vrana, http://php.vrana.cz/* @copyright 2009 Jakub Vrana* @license http://www.apache.org/licenses/LICENSE-2.0
Time of Update: 2016-07-25
網路上一搜,到處都是的「PHP轉拼音」,但是代碼只支援GB2312, 連「騫」、「鶩」、「慧」等字都無法支援。 對於中文姓名轉拼音,那個代碼遠遠不夠使用。 現在公布一個正確的GBK轉拼音代碼,很感謝原作者: 馬明練(!hightman) 首頁: http://php.twomice.net 原DEMO只支援一個字查詢,我修改了成支援一段字串,中英文均可,英文返回原文,漢字轉化為拼音,並帶音調。 暫不支援多音字,例如「曾」會轉化為ceng2,而沒有zeng1 (網路上有一個yii-
Time of Update: 2016-07-25
這是一個網上的代碼,無需資料庫,將要縮短的網址存在於一個同目錄裡的txt檔案裡。 示範:http://www.ucmbaa.org/u/ 目的一是縮短了網址,二是不讓搜尋引擎識別這個地址。 /*location of file to store URLS*/$file = 'urls.txt';/* use mod_rewrite: 0 - no or 1 -
Time of Update: 2016-07-25
之前看到有人發布的飛信介面,醉翁之意不在酒, 用來賣錢的,BS之。。。 自己抽空寫了一個,拿出來跟大家分享,寫的不好的地方大家可以提出來,共同探討學習。 要求:必須是移動使用者,其次需要互為飛信好友才行,不管怎麼玩遊戲,遊戲規則是不能違背的哈。 ============================================================= 項目說明如下: index.php => 線上發送飛信的入口頁 demo.php =
Time of Update: 2016-07-25
php 簡訊介面,基本上解決 了,php調用簡訊介面出現的亂碼問題,代碼並不複雜,但還是實用的. 以下簡訊介面支援長簡訊,支援回複,在這裡,我只把發送的功能分享一下,有需要的朋友,可以參考一下56簡訊網 網址是:http://www.56dxw.com 速度挺不錯的哦. reg.php
Time of Update: 2016-07-25
錢程貸---程式員“錢”“程”無憂貸款要求年齡: 22歲-55歲利率: 最低7.8厘(借10000,利息78元/月)貸款額度:最高1000000.00期限: 3個月-10年放款時間:最快當天申請資料:身份證、半年銀行流水、收入證明、現居住地址證明地區限制:限廣州佛山兩地貸前服務:1.網上遞交申請資料,24小時客服線上2.貸款經理上門收取貸款資料。3.貸款期內提供專屬的貸款顧問,隨時諮詢貸後服務:1.在還款期內周轉有問題,可協助申請應急貸款5056611_103305921000
Time of Update: 2016-07-25
使用此代碼,可以將任何電子郵件地址編碼為 html 字元實體,以防止被垃圾郵件程式收集。 function encode_email($email='info@domain.com', $linkText='Contact Us', $attrs ='class="emailencoder"' ){ // remplazar aroba y puntos $
Time of Update: 2016-07-25
class Test{ private $k=1; public function __get($propertyName){ return 123; }}$obj = new Test();echo json_encode(empty($obj->k)); //trueecho json_encode(isset($obj->k)); //falseecho json_encode((bool)($obj->k)); //true?>複製代碼string 轉
Time of Update: 2016-07-25
error_reporting(E_ALL); set_time_limit(0); echo "TCP/IP Connection\n"; $port = 1935; $ip = "127.0.0.1"; /* +------------------------------- * @socket串連整個過程 +------------------------------- * @socket_create * @socket_connect *
Time of Update: 2016-07-25
/** * Miscellaneous utility methods. */final class Utils { private function __construct() { }/** * Redirect to the given page. * @param type $page target page * @param array $params page parameters */ public static
Time of Update: 2016-07-25
class Person { private $name; private $age; private $id; function __construct( $name, $age ) { $this->name = $name; $this->age = $age; } function setId( $id ) { $this->id = $id; } function _
Time of Update: 2016-07-25
/*** isset — 檢測變數是否設定* 如果 變數 存在則返回 true, 否則返回 false** empty — 檢查一個變數是否為空白* 如果 變數 是非空或非零的值,則 empty() 返回 false**/$is_var = '';if(isset($is_var)) { echo "變數存在!";} else { echo "變數不存在!";}if(empty($is_var)) { echo "變數為空白!";} else {
Time of Update: 2016-07-25
class A{ private function __construct(){} }$a = new A();?>複製代碼程式運行結果為:Fatal error: Call to private A::__construct() from invalid context in E:\PHPProjects\test.php on line 6我們已經禁止外部用new執行個體化這個類,我們改如何讓使用者訪問這個類呢?前門堵了,我們需要給使用者留個後門。解決辦法是:static
Time of Update: 2016-07-25
$ch = curl_init();curl_setopt($ch, CURLOPT_URL, "http://localhost/2.php");curl_setopt($ch, CURLOPT_HTTPHEADER, array('X-FORWARDED-FOR:8.8.8.8', 'CLIENT-IP:8.8.8.8'));//IPcurl_setopt($ch, CURLOPT_REFERER, "http://bbs.it-home.org/ ");
Time of Update: 2016-07-25
php即可以在web頁面上執行,又可以通過PHP CLI(命令列介面)在命令列執行PHP指令碼。php即可以在web頁面上執行,又可以通過PHP CLI(命令列介面)在命令列執行PHP指令碼。# 不帶參數的執行格式php安裝目錄/bin/php scriptname.php# 帶參數的執行格式php安裝目錄/bin/php scriptname.php [參數1] [參數2] .....在scriptname.php通過$argv和$argc訪問參數#