PHP實現簡單的對稱式加密和解密方法

/** * 通用加密 * @param String $string 需要加密的字串 * @param String $skey 加密EKY * @return String */function enCode($string = '', $skey = 'echounion') { $skey = array_reverse(str_split($skey)); $strArr = str_split(base64_encode($string)); $strCount =

PHP實現防止sql注入的通用方法

function inject_check($sql_str) { return eregi('select|insert|and|or|update|delete|\'|\/\*|\*|\.\.\/|\.\/|union|into|load_file|outfile', $sql_str);} function verify_id($id=null) { if(!$id) { exit('沒有提交參數!'); } elseif(inject_check($

php 解壓rar檔案的代碼

對於zip檔案網上的例子很多,rar檔案解壓php沒有直接支援,可以用pecl 到http://pecl.php.net/package/rar 下載對應版本的 非安全執行緒的dll 然後扔到php的 ext目錄下。 開啟php.ini. 加一行 extension=php_rar.dll 重啟web伺服器 和php public function _unzip($fileName,$extractTO){

PHP實現壓縮html的函數

function compress_html($string) { $string = str_replace("\r\n", '', $string); //清除分行符號 $string = str_replace("\n", '', $string); //清除分行符號 $string = str_replace("\t", '', $string); //清除定位字元 $pattern = array ( "/> *([^ ]*

PHP實現遞迴建立多級目錄的通用方法

/** * +-------------------------------------------------------------------- * Description 遞迴建立目錄 +-------------------------------------------------------------------- * @param string $dir 需要創新的目錄 +----------------------------------------------------

通過php的 similar_text函數比較兩個字串的相似性

通過php的 similar_text函數比較兩個字串的相似性 $word2compare = "stupid"; $words = array( 'stupid', 'stu and pid', 'hello', 'foobar', 'stpid', 'upid', 'stuuupid', 'sstuuupiiid',); while(list($id, $str) = each($words)){ similar_text($str,

PHP實現擷取中文的首頁字母方法

function getfirstchar($s0) {$fchar = ord(substr($s0, 0, 1));if (($fchar >= ord("a") and $fchar = ord("A") and $fchar $s = iconv("UTF-8", "gb2312", $s0);$asc = ord($s{0}) * 256 + ord($s小貝)-65536;if ($asc >= -20319 and $asc if ($asc >= -20283 and $asc

php把一個顏色變深的函數

這個php函數可以把指定的顏色變得更深一些 function ColorDarken($color, $dif=20){ $color = str_replace('#', '', $color); if (strlen($color) != 6){ return '000000'; } $rgb = ''; for ($x=0;$x $c = hexdec(substr($color,(2*$x),2)) - $dif; $c =

PHP實現下載圖片的通用方法

function getPicture($url,$pictureName){if ($url == "") return false;//擷取圖片的副檔名$info = getimagesize($url);$mime = $info['mime'];$type = substr(strrchr($mime,'/'), 1);//不同的圖片類型選擇不同的圖片產生和儲存函數switch($type){case 'jpeg':$img_create_func =

PHP實現資料分頁的通用方法

function show_page($count,$page,$page_size){$page_count = ceil($count/$page_size); //計算得出總頁數$init=1;$page_len=7;$max_p=$page_count;$pages=$page_count;//判斷當前頁碼$page=(empty($page)||$page//擷取當前頁url$url =

PHP實現用迭代實現數組的快速排序

function quicksortX(&$seq){ $stack = array($seq); $sort = array(); while ($stack) { $arr = array_pop($stack); if(count($arr) if (count($arr) == 1) { $sort[] = &$arr[0]; }

php計算整個mysql資料庫的大小

php計算串連的mysql資料庫的大小,用MB,KB或者GB的格式返回 function CalcFullDatabaseSize($database, $db) { $tables = mysql_list_tables($database, $db); if (!$tables) { return -1; } $table_count = mysql_num_rows($tables); $size = 0; for ($i=0; $i

PHP實現人民幣數字格式化,每三位加逗號

function num_format($num){if(!is_numeric($num)){return false;}$rvalue='';$num = explode('.',$num);//把整數和小數分開$rl = !isset($num['1']) ? '' : $num['1'];//小數部分的值$j = strlen($num[0]) % 3;//整數有多少位$sl = substr($num[0], 0, $j);//前面不滿三位的數取出來$sr = substr($num[

PHP實現計算一個檔案夾的大小

function dirSize($directoty){$dir_size=0;if($dir_handle=@opendir($directoty)){while($filename=readdir($dir_handle)){$subFile=$directoty.DIRECTORY_SEPARATOR.$filename;if($filename=='.'||$filename=='..'){continue;}elseif

PHP檔案上傳樣本

處理代碼: header('Content-Type:text/html;charset=UTF-8'); //準備接收 /* echo '檔案名稱:'.$_FILES['userfile']['name']; echo '檔案大小:'.$_FILES['userfile']['size']; echo '錯誤:'.$_FILES['userfile']['error']; */

PHP實現漢字轉整型數字,如:一百零一 轉成101

test();/** * 測試 */function test() { echo CnToInt('一'); // 1 echo CnToInt('十'); // 10 echo CnToInt('十一'); // 11 echo CnToInt('一百一十'); // 110 echo CnToInt('一千零一'); // 1001 echo CnToInt('一萬零一百零一'); // 10101 echo

PHPMailer發送郵件

require './class.phpmailer.php';$mail=new

PHP實現計算兩個時間戳記之間的時間長度

/** * 返回兩個時間的相距時間,*年*月*日*時*分*秒 * @param int $one_time 時間一 * @param int $two_time 時間二 * @param int $return_type 預設值為0,0/不為0則拼接返回,1/*秒,2/*分*秒,3/*時*分*秒/,4/*日*時*分*秒,5/*月*日*時*分*秒,6/*年*月*日*時*分*秒 * @param array $format_array 格式化字元,例,array('年', '月', '日', '時'

使用單例模式實現mysql類

defined('ACC')||exit('Access Denied');// 封裝mysql操作類,包括串連功能,及查詢功能.class mysql extends absdb{ protected static $ins = null; protected $host; // 主機名稱 protected $user; // 使用者名稱 protected $passwd; // 密碼 protected $db; // 資料庫名

PHP檔案讀寫

$handle = @ fopen ( "demo.txt" , "r" ); if ( $handle ) { while (( $buffer = fgets ( $handle , 4096 )) !== false ) { echo $buffer ; } if (! feof ( $handle )) { echo "Error: unexpected

總頁數: 5203 1 .... 1677 1678 1679 1680 1681 .... 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.