php簡單驗證碼的製作

$image=imagecreatetruecolor(100, 30);$white=imagecolorallocate($image, 255, 255, 2);$red=imagecolorallocate($image, 255, 0, 0);imagefill($image, 0, 0, $white);//munber create$num="";for($i=0;$i $num.=rand(1,9);}imagestring($image, 6, rand(10,

PHP目錄操作

//basename()返迴路徑中的檔案名稱部分$path="D:/lamp/apache2/htdocs/file.php";echo basename($path)."";//顯示帶有副檔名的檔案名稱echo basename($path,'php')."";//顯示不帶副檔名的檔案名稱//dirname()去掉檔案名稱,返回目錄名echo dirname($path)."";//返回目錄名//pathinfo()返回一個關於路徑屬性的數組print_r(pathinfo($path))."

php根據詞頻產生tag雲

給定一段文本,此程式碼分析文本的詞頻分布,產生tag雲 /** * Tag cloud demo based on word frequency * @author: unknown * @since: 2007-02-27 */ // Store frequency of words in an array$freqData = array(); // Random words$lorem = "Lorem ipsum dolor sit amet, consectetuer

PHP簡單的圖片驗證碼實現

//第一段代碼產生隨機圖片------code2.php //開啟session以用於儲存產生的內容session_start();$table=array( "pic0"=>"dog", "pic1"=>"cat", "pic2"=>"fish", "pic3"=>"bird");$index=rand(0,3);$value=$table['pic'.$index];

phpRegex取得內容所有連結的方法

本文執行個體講述了phpRegex取得內容所有連結的方法。分享給大家供大家參考。具體如下: 這裡提供二款關於php正則連結的方法,他們可以取得內容所有連結並且儲存到一個數組,當然也可以把連結全部替換. 方法一,代碼如下: function get_all_url($code){ preg_match_all('/"' ]+)["|']?s*[^>]*>([^>]+)/i',$code,$arr); return array('name'=>$arr[2],

PHP陽曆轉農曆實現代碼

PHP陽曆到農曆轉換的一個類代碼 //PHP陽曆到農曆轉換的一個類class Calendar{#農曆每月的天數 var $everyCMonth=array( 0=>array(8,0,0,0,0,0,0,0,0,0,0,0,29,30,7,1), 1=>array(0,29,30,29,29,30,29,30,29,30,30,30,29,0,8,2), 2=>array(0,30,29,30,29,29,30,29,30,29,30,30,30,0,9,3),

PHP將秒數轉換為時間(年、月、日、小時…)

這個有用的函數能將秒數表示的事件轉換為年、月、日、小時等時間格式 function Sec2Time($time){if(is_numeric($time)){$value = array("years" => 0, "days" => 0, "hours" => 0,"minutes" => 0, "seconds" => 0,);if($time >= 31556926){$value["years"] = floor($time/31556926);$time = ($time%3155

PHP實現漢字或英文按照首字母尋找

/** * */ function getfirstchar($s0){ if($s0[0]=='I' || $s[0]=='i'){ return "I"; }elseif($s0[0]=='U' || $s[0]=='u'){ return 'U'; }elseif($s0[0]=='V' ||

PHP 中根據經度和緯度計算距離

這是一個非常有用的距離計算函數,利用緯度和經度計算從 A 地點到 B 地點的距離。該函數可以返回英裡,公裡,海裡三種單位類型的距離。 function distance($lat1, $lon1, $lat2, $lon2, $unit) { $theta = $lon1 - $lon2;$dist = sin(deg2rad($lat1)) * sin(deg2rad($lat2)) + cos(deg2rad($lat1)) * cos(deg2rad($lat2)) * cos(deg2

PHP格式化時間,幾分鐘前,幾小時前

//格式化時間,幾分鐘前,幾小時前 function format_date($time){ $t = time()-$time; $f = array( '31536000'=>'年', '2592000'=>'個月', '604800'=>'星期', '86400'=>'天', '3600'=>'小時',

使用PHPMailer來發送帶圖片的 HTML Emails

require("class.phpmailer.php");$mail = new PHPMailer();$mail = new PHPMailer();$mail->IsSMTP();$mail->Host = "smtp1.example.com;smtp2.example.com";$mail->SMTPAuth = true;$mail->Username = 'smtpusername';$mail->Password = 'smtppassword'; $mail->From="

PHP 多維陣列進行排序

/* function:二維數組按指定的索引值排序 $array=array( 0=>array('id'=>8,'username'=>'phpernote'), 1=>array('id'=>9,'username'=>'com'), 2=>array('id'=>5,'username'=>'www') ); 現在需要將這個二維數組按id升序排列,則: array_sort($array,'id','asc'); */ public function array_

通過IP地址取得所在國家的PHP代碼

function getLocationInfoByIp(){ $client = @$_SERVER['HTTP_CLIENT_IP']; $forward = @$_SERVER['HTTP_X_FORWARDED_FOR']; $remote = @$_SERVER['REMOTE_ADDR']; $result = array('country'=>'', 'city'=>''); if(filter_var($client, FILTER_VALIDATE_IP)){ $ip =

PHP 添加浮水印 & 比例縮圖 & 固定高度 & 固定寬度 類。

//PHP 添加浮水印 & 比例縮圖 & 固定高度 & 固定寬度 類。 class Image_process{ public $source; //原圖 public $source_width; //原圖寬度 public $source_height; //原圖高度 public $source_type_id; public $orign_name; public $orign_dirname; /

php的web路徑擷取

class HttpTool{ /** * //擷取網域名稱或主機地址 * #測試網址: http://localhost:8081/test/testurl.php?id=5 * 返回 localhost:8081 */ public function getHost() { return $_SERVER['HTTP_HOST']; } /** * 當前頁面的url(包括參數)

PHP 遠程圖片擷取到本地

/* * 遠程圖片擷取到本地 */ function GrabImage($url){ if($url != ""){ //如果圖片地址為空白 $ext = strrchr($url,'.'); //判斷圖片的格式 if($ext != '.jpg' && $ext != '.gif' && $ext != '$png'){ return

利用PHP實現短網址功能

function shorturl($url){ $length = strlen($url); if($length > 45){ $length = $length - 30; $first = substr($url, 0, -$length); $last = substr($url, -15); $new = $first."[ ... ]".$last; return $new; }else{ return $url; }}?> // USAGE $longurl= "http:/

擷取字串中數位Regex

$patterns = "/\d+/"; //第一種 //$patterns = "/\d/"; //第二種 $strs="left:0px;top:202px;width:90px;height:30px"; preg_match_all($patterns,$strs,$arr); print_r($arr); /***************運行結果*********************/ //第一種Array( [0] => Array

實現的支援斷點續傳的檔案下載php類

本文執行個體講述了php實現的支援斷點續傳的檔案下載類及其用法,是非常實用的技巧。分享給大家供大家參考。具體方法如下: 通常來說,php支援斷點續傳,主要依靠HTTP協議中 header HTTP_RANGE實現。 HTTP斷點續傳原理: Http頭 Range、Content-Range() HTTP頭中一般斷點下載時才用到Range和Content-Range實體頭, Range使用者要求標頭中,指定第一個位元組的位置和最後一個位元組的位置,如(Range:200-300)

ftp上傳檔案的php指令碼

大概原理 遍曆項目中的所有非排除檔案,然後擷取 檔案修改時間晚於檔案上一次修改時間 的檔案 然後將這些檔案,通過ftp上傳到對應的目錄 具體代碼如下: 因為只是工具,代碼很亂,見諒 error_reporting(7);if ($_SERVER['SERVER_ADDR'])exit;//禁止在web伺服器下運行$_GET['exclude'] =

總頁數: 5203 1 .... 1692 1693 1694 1695 1696 .... 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.