一個計算php頁面已耗用時間的函數

/*計算php程式已耗用時間*/function microtime_float(){list($usec, $sec) = explode(” “, microtime());return ((float)$usec + (float)$sec);}//開始計時,放在頭部$starttime = microtime_float();//結束計時,放在最底部$runtime = number_format((microtime_float() – $starttime),

php寫的Passport加密函數

/*** Passport 加密函數** @param string 等待加密的原字串* @param string 私人密匙(用於解密和加密)** @return string 原字串經過私人密匙加密後的結果*/function passport_encrypt($txt, $key) {// 使用隨機數發生器產生 0~32000 的值並 MD5()srand((double)microtime() * 1000000);$encrypt_key =

php寫的一個刪除目錄的函數

// 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

php擷取線上訪客Ip地址資訊的方法

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 =

php單例模式的示範代碼

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() //

安裝redis和phpredis模組一例

@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測試命令:

加強版的htmlspecialchars函數

//取消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});)/’,

尋找技術牛人、創業夥伴

本公司正在構建一個以分享經濟為主題的大型行業交易平台,尋找懂網站平台開發,熟悉PHP、MySQL、JAVA、Android、iOS,能獨立完成網站架構和組織項目開發的技術牛人作為創業夥伴,籌備期您可以兼職的方式參與,最大限度減輕您的機會成本,有意者請發郵件至2975782162@qq.com。本公司將會擇優安排面談。

又一個產生圖片縮圖的函數

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!");

php擷取中文字串長度的方法

$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?>

一個判斷是否為指定長度內字串的函數

//// 函數名: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

有關phpmailer的用法

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 =

一個比較穩定的php登陸系統驗證碼

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 =

php實現的一個UTF8編碼轉Unicode的函數

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

UTF-8與GBK編碼下PHP擷取字串長度的函數

/** 統計字串長度*@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;}

一個比較全面的截取函數(多用於採集內容的分析)

/*採集截取函數,主要用於分析採集的內容getcon - 截取後去掉html字元,並去掉空格getcon2 - 單純截取,直接返回截取內容。參數:$par可接受兩種格式:1.前面字元{DATA}後面字元2.Regex*/function getcon($pat,$str){ $title_var=explode("{DATA}",$pat); if(count($title_var)>1){

有關php中session的疑惑

有關php中session的疑惑,請仔細閱讀本文,相信你必有收穫。有關php中session的疑惑,請仔細閱讀本文,相信你必有收穫。一、PHP

windows下php開啟curl_init的方法

測試類比登入時,提示:“Call to undefined function curl_init”。為什麼會提示:沒有定義的函數呢?原因在於php未開啟對curl_init函數的支援。測試類比登入時,提示:“Call to undefined function

判斷是否有包括中文的字串的小函數

/*可用於使用者名稱等不允許使用出現中文字元的地方*///--樣本$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;}}?>複製代碼

PHP遠程圖片儲存到本地

簡單的檔案操作,遠程圖片儲存本地。 function get_file($url,$folder,$pic_name){set_time_limit(24*60*60); //限制最大的執行時間$destination_folder=$folder?$folder.'/':''; //檔案下載儲存目錄$newfname=$destination_folder.$pic_

總頁數: 5203 1 .... 1799 1800 1801 1802 1803 .... 5203 Go to: 前往

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.