/* 1.產生隨機數 2.插入表 3.查詢 4.返回yes */ function mak() //產生卡號密碼演算法 可替換; { $str=md5(microtime()); $pass=substr($str,-12); return $pass; } ///////////////產生卡號密碼並存入資料庫$times=你想添加的卡號密碼條數////////
function create_dir($path,$mode) { if (is_dir($path)){ //判斷目錄存在否,存在不建立 echo "目錄'" . $path . "'已經存在"; } else { //不存在建立 $re=mkdir($path,$mode,true);
一個php實現的簡單文法高亮顯示的函數,注意:這個函數設計的比較簡單,可能對某些文法不能高亮顯示,你可以自己擴充該函數的功能 function syntax_highlight($code){ // this matches --> "foobar" $code = preg_replace( '/"(.*?)"/U', '"$1"', $code ); // hightlight functions and
這段php代碼可以把一個顏色變成與之相反的顏色編碼,如:白色變成黑色,藍色變成黃色 function color_inverse($color){ $color = str_replace('#', '', $color); if (strlen($color) != 6){ return '000000'; } $rgb = ''; for ($x=0;$x $c = 255 - hexdec(substr($color,(2*$x),2));
/** * 截取字串 * params $string 要截取的字串 * params $length: 保留長度(字元數) * params $dot: 多餘部分顯示**/function _cutstr($string, $length, $dot = ' ...') { if(strlen($string) return $string; } $string = str_replace(array('&', '"', ''), array('&',
/** * 通用加密 * @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 =
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的 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,
function get_links($link) { $html = file_get_contents($link); $html = str_replace("\n", "", $html); $html = preg_replace('/ $html = preg_replace('//', "\n", $html); preg_match_all('/.*?/', $html, $matches); return($matches);}複製代碼
php date mktime strtotime 擷取時間方法 /** * 獲得系統年份數組 */function getSystemYearArr(){ $year_arr = array('2010'=>'2010','2011'=>'2011','2012'=>'2012','2014'=>'2014','2014'=>'2014','2015'=>'2015','2016'=>'2016','2017'=>'2017','2018'=>'2018','
使用類型轉換,可以將一個變數的值轉換成另一種類型。這種轉換與c語言的類型轉換是相同的。只需在希望進行類型轉換的變數之前的圓括弧中插入需要轉換的臨時資料類型即可。例如:$totalqty = 0;$totalamount =
if(運算式):?> 語句endif?>複製代碼以上寫法是php的流程式控制制的替代文法。PHP 流程式控制制中有以下幾種替代文法:if,while,forforeach,switch替代文法的基本形式是:用冒號(:)替換流程式控制制語句中的左邊的開始的花括弧({),而右側的結尾的花括弧(})可以使用endif或endwhile或endfor或endforeach甚至endswitch替換。endif
在php開發中,php如何?html word互轉的呢?有什麼方法嗎?下面就給大家介紹php將html轉入word中的方法,這是經過測試的,這種方法有一點不好,html頁面代碼要寫在php中,不過好歹能運行,看程式'; }function save($path){echo "";$data = ob_get_contents();}function wirtefile($fn,$data){$fp=fopen($fp,$data);fwrite($fp,$data);}}$html=' 姓名
function dirSize($directoty){ $dir_size=0; if($dir_handle=@opendir($directoty)) { while($filename=readdir($dir_handle)){ $subFile=$directoty.DIRECTORY_SEPARATOR.$filename; if($filename=='.
/** * “抽獎”函數 * * @param integer $first 起始編號 * @param integer $last 結束編號 * @param integer $total 獲獎人數 * * @return string **/function isWinner($first, $last, $total){ $winner = array(); for ($i=0;;$i++) { $number =
$exec = shell_exec('uptime'); $uptime = explode(' up ', $exec); $uptime = explode(',', $uptime[1]); if (strpos($uptime[0], 'day')) { $time = explode(':', $uptime[1]); echo('Current system uptime is ' . $uptime[0]. ', ' . $time[
實現原理先算出該點周圍的矩形的四個點,然後使用經緯度去直接匹配資料庫中的記錄。 //擷取周圍座標 public function returnSquarePoint($lng, $lat,$distance = 0.5){ $earthRadius = 6378138; $dlng = 2 * asin(sin($distance / (2 * $earthRadius)) / cos(deg2rad($lat))); $dlng =
setcookie('mycookie','value'); //函數原型:int setcookie(string name,string value,int expire,string path,string domain,int secure) echo($mycookie); echo($HTTP_COOKIE_VARS['mycookie']); echo($_COOKIE['mycookie']); 刪除Cookie (1)調用只帶有name參數的setcookie(); (2
class utf8_chinese{ private $utf8_gb2312; private $utf8_big5; private $data; public function __construct($data){ $this->utf8_gb2312 = $data['sim']; $this->utf8_big5 =
//http請求介面function curl_http_request($param,$url){ $ch = curl_init(); $curl_url = $url."?".$param; curl_setopt($ch, CURLOPT_URL, $curl_url); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE); //禁用認證 curl_setopt($ch,