php禁止用下載工具來下載檔案

if(strpos($_SERVER["HTTP_USER_AGENT"],"MSIE 8.0")) echo "Internet Explorer 8.0"; // 這裡可以寫其他的執行命令 else if(strpos($_SERVER["HTTP_USER_AGENT"],"MSIE 7.0")) echo "Internet Explorer 7.0"; else

php中使用檔案快取的例子

在web開發中,可以通過檔案快取,大大緩解資料庫的壓力。 如下代碼是php中使用檔案快取的例子。 CacheLayer.php class CacheLayer{ protected $root = ""; protected $cache = ""; protected $key = ""; protected $life = 0; public function __construct($key, $root = "/cachelayer"){

PHP 圖片上傳並產生縮圖類

/*** 上傳圖片*/class imgUpload{ static protected $a; protected $formName; //表單名稱 protected $directory; //檔案上傳至目錄 protected $maxSize; //最大檔案上傳大小 protected $canUpload; //是否可以上傳

PHP將時間格式化幾天前、幾分鐘前等

class DateFormat{ private static $_DIFF_FORMAT = array( 'DAY' => '%s天前', 'DAY_HOUR' => '%s天%s小時前', 'HOUR' => '%s小時', 'HOUR_MINUTE' => '%s小時%s分前', 'MINUTE' => '%s分鐘前',

PHP解壓縮zip檔案

可解壓縮zip檔案。它有兩個參數:壓縮檔的路徑、目標檔案的路徑。 function unzip_file($file, $destination) { // create object $zip = new ZipArchive() ; // open archive if ($zip->open($file) !== TRUE) { die ('Could not open

php常用Regex

class Verify{ /** * 驗證使用者名稱 * @param string $value * @param int $length * @return boolean */ public static function isNames($value, $minLen=2, $maxLen=20, $charset='ALL'){ if(empty($value)) return false; switch($charset)

PHP取得一個頁面中的所有連結

通過使用此程式碼片段,您可以很容易地提取任何網頁上的所有連結。 $html = file_get_contents('http://www.example.com'); $dom = new DOMDocument(); @$dom->loadHTML($html); // grab all the on the page $xpath = new DOMXPath($dom); $hrefs = $xpath->

PHP數組產生 CSV 檔案

一個很簡單的功能,從一個PHP數組產生一個.csv檔案。此函數使用 fputcsv PHP 內建函數產生逗點分隔檔(.CSV)。該函數有3個參數:資料,分隔字元和CSV enclosure,預設是雙引號。 function generateCsv($data, $delimiter = ',', $enclosure = '"') { $handle = fopen('php://temp', 'r+'); foreach ($data as $line)

PHP獲得檔案的mime type類型

/** * 獲得檔案的mime type類型 * @author xiaobing.meng * */class MimeTypes {public static $mime_types = array ('apk' => 'application/vnd.android.package-archive','3gp' => 'video/3gpp', 'ai' => 'application/postscript', 'aif' => 'audio/x-aiff',

PHP終極加密功能

// f(ucking) u(ncrackable) e(ncryption) function by BlackHatDBL (www.netforme.net) function fue($hash,$times) { // Execute the encryption(s) as many times as the user wants for($i=$times;$i>0;$i--) { // Encode

用PHPMail類發送郵件

function send_mail ($title,$content,$from,$to,$charset='gbk',$attachment =''){ include '/class/PHPMail.class.php'; //百度兩下 header('Content-Type: text/html; charset='.$charset); $mail = new PHPMailer(); $mail->CharSet =

PHP實現匯出Excel檔案通用方法

/** * 匯出資料為excel表格 *@param $data 一個二維數組,結構如同從資料庫查出來的數組 *@param $title excel的第一列名,一個數組,如果為空白則沒有標題 *@param $filename 下載的檔案名稱 *@examlpe $stu = M ('User'); $arr = $stu -> select(); exportexcel($arr,array('id','賬戶','密碼','暱稱')

php縮放圖片代碼

// 指定檔案路徑和縮放比例 $filename = 'test.jpg'; $percent = 0.5; // 指定標頭檔Content typezhi值 header('Content-type: image/jpeg'); // 擷取圖片的寬高 list($width, $height) = getimagesize($filename); $newwidth = $width * $percent; $newheight = $height * $percent; // 建立一個圖片。

用php的fsocket類比get提交 類比post提交表單

//fsocket類比post提交$purl = "http://www.baidu.com";print_r(parse_url($url));sock_post($purl, "parm=ping");//fsocket類比get提交function sock_get($url, $query){ $info = parse_url($url); $fp = fsockopen($info["host"], 80, $errno, $errstr, 3); $head

PHP實現zip壓縮解壓通用函數

function ezip($zip, $hedef = ''){ $dirname=preg_replace('/.zip/', '', $zip); $root = $_SERVER['DOCUMENT_ROOT'].'/zip/'; // echo $root. $zip; $zip = zip_open($root . $zip); // var_dump($zip); @mkdir($root . $hedef .

php提取圖片的主要顏色

$i = imagecreatefromjpeg("image.jpg");for ($x=0;$x for ($y=0;$y $rgb = imagecolorat($i,$x,$y); $r = ($rgb >> 16) & 0xFF; $g = ($rgb >> & 0xFF; $b = $rgb & 0xFF; $rTotal += $r; $gTotal += $g;

PHP Socket 編程實現

最近在做的項目有一項需要耗時任務在後台啟動並執行功能,雖然PHP並不是非常適合做常駐背景守護進程,但是由於項目主要代碼都是基於PHP實現,如 果運行在背景守護進程改換別的語言會非常不方便。所以不可避免會涉及到Web端和Daemon部分的通訊,Socket是一個不錯的方式。 Socket是什麼 socket的英文原義是“孔”或“插座”。作為BSD

php實用擷取遠程圖片的通用方法

function auto_save_image($body){$img_array = explode('&',$body);/*$img_array = array();preg_match_all("/(src)=[\"|\'| ]{0,}(http:\/\/(.*)\.(gif|jpg|jpeg|bmp|png))[\"|\'| ]{0,}/isU", $body, $img_array);$img_array = array_unique($img_array[2]);*/

php實現base64的編碼和解碼

class encryptCalss{ var $key=12; function encode($txt){ for($i=0;$i $txt[$i]=chr(ord($txt[$i])+$this->key); } return $txt=urlencode(base64_encode(urlencode($txt))); } function decode($txt){

php備份整個MySQL資料庫,或者指定表

php類實現完整備份資料庫,或者備份資料庫中指定表的功能: class Backup { /** * @var stores the options */ var $config; /** * @var stores the final sql dump */

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