Time of Update: 2016-07-25
/*計算php程式已耗用時間*/function microtime_float(){list($usec, $sec) = explode(” “, microtime());return ((float)$usec + (float)$sec);}//開始計時,放在頭部$starttime = microtime_float();//結束計時,放在最底部$runtime = number_format((microtime_float() – $starttime),
Time of Update: 2016-07-25
/*** Passport 加密函數** @param string 等待加密的原字串* @param string 私人密匙(用於解密和加密)** @return string 原字串經過私人密匙加密後的結果*/function passport_encrypt($txt, $key) {// 使用隨機數發生器產生 0~32000 的值並 MD5()srand((double)microtime() * 1000000);$encrypt_key =
Time of Update: 2016-07-25
// ggarciaa at gmail dot com (04-July-2007 01:57)// I needed to empty a directory, but keeping it// so I slightly modified the contribution from// stefano at takys dot it (28-Dec-2005 11:57)// A short but powerfull recursive function// that works
Time of Update: 2016-07-25
if(getenv('HTTP_CLIENT_IP') && strcasecmp(getenv('HTTP_CLIENT_IP'), 'unknown')) { $onlineip = getenv('HTTP_CLIENT_IP');} elseif(getenv('HTTP_X_FORWARDED_FOR') && strcasecmp(getenv('HTTP_X_FORWARDED_FOR'), 'unknown')) { $onlineip =
Time of Update: 2016-07-25
class User { static function getInstance() { if (self::$instance == NULL) { // If instance is not created yet, will create it. self::$instance = new User(); } return self::$instance; } private function __construct() //
Time of Update: 2016-07-25
@ubuntu:/$ mkdir /usr/local/redis@ubuntu:/$ cd /usr/local/redis@ubuntu:/$ wget http://redis.googlecode.com/files/redis-2.4.2.tar.gz@ubuntu:/$ tar xzf redis-2.4.2.tar.gz@ubuntu:/$ cd redis-2.4.2@ubuntu:/$ make@ubuntu:/$ src/redis-server複製代碼redis測試命令:
Time of Update: 2016-07-25
//取消html代碼function shtmlspecialchars($string) {if(is_array($string)) {foreach($string as $key => $val) {$string[$key] = shtmlspecialchars($val);}} else {$string = preg_replace(‘/&((#(\d{3,5}|x[a-fA-F0-9]{4})|[a-zA-Z][a-z0-9]{2,5});)/’,
Time of Update: 2016-07-25
本公司正在構建一個以分享經濟為主題的大型行業交易平台,尋找懂網站平台開發,熟悉PHP、MySQL、JAVA、Android、iOS,能獨立完成網站架構和組織項目開發的技術牛人作為創業夥伴,籌備期您可以兼職的方式參與,最大限度減輕您的機會成本,有意者請發郵件至2975782162@qq.com。本公司將會擇優安排面談。
Time of Update: 2016-07-25
function photoThumb($p_thumb_file, $p_photo_file, $p_max_size, $p_quality = 75) { $pic = @imagecreatefromjpeg($p_photo_file); if ($pic) { $thumb = @imagecreatetruecolor ($p_max_size, $p_max_size) or die ("Can't create Image!");
Time of Update: 2016-07-25
$str = 'Hello world!';echo strlen($str); // 輸出12?> 複製代碼然而在PHP內建的函數中,strlen及mb_strlen都是通過計算字串所佔位元組數來計算長度的,在不同的編碼情況下,中文所佔的位元組數是不同的。在GBK/GB2312下,中文字元佔2個位元組,而在UTF-8下,中文字元佔3個位元組。 $str = '你好,世界!';echo strlen($str); // GBK或GB2312下輸出12,UTF-8下輸出18?>
Time of Update: 2016-07-25
//// 函數名:CheckLengthBetween($C_char, $I_len1, $I_len2=100)// 作 用:判斷是否為指定長度內字串// 參 數:$C_char(待檢測的字串)// $I_len1 (目標字串長度的下限)// $I_len2 (目標字串長度的上限)// 傳回值:布爾值// 備 註:無function CheckLengthBetween($C_cahr, $I_len1, $I_len2=100){$C_cahr = trim($C_cahr);if
Time of Update: 2016-07-25
require("phpmailer/class.phpmailer.php"); function smtp_mail( $sendto_email, $subject, $body, $extra_hdrs, $user_name){ $mail = new PHPMailer(); $mail->IsSMTP(); // send via SMTP $mail->Host =
Time of Update: 2016-07-25
session_start(); $type = 'gif'; $width= 56; $height= 22; header("Content-type: image/".$type); srand((double)microtime()*1000000); $randval = randStr(4,"NUMBER"); if($type!='gif' && function_exists('imagecreatetruecolor')){ $im =
Time of Update: 2016-07-25
function Utf8ToUnicode(strUtf8){var bstr = “”;var nTotalChars = strUtf8.length; // total chars to be processed.var nOffset = 0; // processing point on strUtf8var nRemainingBytes = nTotalChars; // how many bytes left to be convertedvar
Time of Update: 2016-07-25
/** 統計字串長度*@param $str 被統計字串*/function sstrlen($str) {global $charset;$n = 0; $p = 0; $c = ”;$len = strlen($str);if($charset == ‘utf-8′) {for($i = 0; $i $c = ord($str{$i});if($c > 252) {$p = 5;} elseif($c > 248) {$p = 4;} elseif($c > 240) {$p = 3;}
Time of Update: 2016-07-25
/*採集截取函數,主要用於分析採集的內容getcon - 截取後去掉html字元,並去掉空格getcon2 - 單純截取,直接返回截取內容。參數:$par可接受兩種格式:1.前面字元{DATA}後面字元2.Regex*/function getcon($pat,$str){ $title_var=explode("{DATA}",$pat); if(count($title_var)>1){
Time of Update: 2016-07-25
有關php中session的疑惑,請仔細閱讀本文,相信你必有收穫。有關php中session的疑惑,請仔細閱讀本文,相信你必有收穫。一、PHP
Time of Update: 2016-07-25
測試類比登入時,提示:“Call to undefined function curl_init”。為什麼會提示:沒有定義的函數呢?原因在於php未開啟對curl_init函數的支援。測試類比登入時,提示:“Call to undefined function
Time of Update: 2016-07-25
/*可用於使用者名稱等不允許使用出現中文字元的地方*///--樣本$str = “dd*(*d”;if (iscn($str)) {echo “包括中文的字串”;} else {echo “不包括中文的字串”;}//--函數function iscn($str){if (preg_match(“/.*[".chr(0xa1)."-".chr(0xff)."]+.*/”, $str)) {return true;} else {return false;}}?>複製代碼
Time of Update: 2016-07-25
簡單的檔案操作,遠程圖片儲存本地。 function get_file($url,$folder,$pic_name){set_time_limit(24*60*60); //限制最大的執行時間$destination_folder=$folder?$folder.'/':''; //檔案下載儲存目錄$newfname=$destination_folder.$pic_