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檔案讀寫

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

php中使用檔案快取的例子

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

使用XHGui來測試PHP效能的教程

Profiling是一項用來觀察程式效能的技術,非常適用於發現程式的瓶頸或者緊張的資源。Profiling能夠深入程式的內部,展現request處理過程中每一部分代碼的效能;同時,也可以確定有問題的請求(request);對於有問題的請求,我們還可以確定效能問題發生在請求內部的位置。對於PHP,我們有多種Profiling工具,本文主要集中在——XHGui,一款非常優秀的工具。XHGui構建在XHProf之上(XHProf由Facebook發布),但是對於剖析結果增加了更好的儲存,同時增加了更加

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使用imagecopy()拼接圖片

php使用imagecopy()拼接圖片 header("Content-type: image/jpeg"); $src_image[0] = imagecreatefromgif("./1.jpg");$src_image[1] = imagecreatefromgif("./2.jpg"); $dest = imagecreatetruecolor(100, 50); //php圖片拼接imagecopy($dest, $src_image[0], 0, 0, 0, 0, 50, 50);

長微博產生工具PHP源碼 根據文字產生長微博圖片

error_reporting(7);define('ROOT', getcwd());define('BASEDIR', parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH));if ($_POST['text']) { $ret = array(); $text = $_POST['text']; try { $ret['imgurl'] = text2img($text, (array)

PDO資料庫操作類

class HRDB{ protected $pdo; protected $res; protected $config; /*建構函式*/ function __construct($config){ $this->Config = $config; $this->connect(); } /*資料庫連接*/ public function connect(){

PHP圖片處理函數 類 (浮水印圖,縮圖)[關於等比例壓縮與裁剪壓縮]

下面簡單的寫了一個圖片處理類,功能包括:浮水印,縮圖等。 不過,對於產生縮圖有兩種方式:一種是直接按比例來壓縮圖片,另外一種是先裁剪再壓縮的方式。在自己看來等例壓縮與裁剪壓縮區別就在於: 等例壓縮:能保證圖片的寬長比例合理,且圖片有完整性。但實際大小不保證符合要求。 裁剪壓縮: 能保證圖片的寬長比例合理,實際大小也能保證。但圖片完整性不能保證。 image.php /** * * 影像處理類 * @author FC_LAMP * @internal功能包含:浮水印,縮圖 */class

PHP把全形數字轉為半形數字

//把全形數字轉為半形數字 function GetAlabNum($fnum){ $nums = array("0","1","2","3","4","5","6","7","8","9");//OSPHP.com.CN$fnums = "0123456789"; for($i=0;$i$fnum = ereg_replace("[^0-9.]|^0{1,}","",$fnum); if($fnum=="") $fnum=0; return

PHP操作Cookie的類

class Cookie{ /** * 解密已經加密了的cookie * * @param string $encryptedText * @return string */ private static function _decrypt($encryptedText) { $key = Config::get('secret_key'); $cryptText =

完整的PHP操作MySQL資料庫類

class database { private $hostname; private $user; private $pass; private $dbname; private $linkflag; private $charset; function __construct() { $this->hostname="localhost";

用開源項目PHPMailer實現郵件發送

這是用開源項目PHPMailer實現郵件發送 ,先下載檔案,我這裡下載得是5.1得版本,然後把三個class.***.php檔案放到專案檔下,我首先用得是 gmail,但是失敗了,問題是認證失敗,後來用了QQ郵箱,發送成功。 require("class.phpmailer.php"); //下載的檔案必須放在該檔案所在目錄$mail = new PHPMailer(); //建立郵件發送類$address ="youbinliu@126.com";$mail->IsSMTP(); //

php按照指定長度截取字串的代碼

php按照指定長度截取字串的代碼,如果字串超出了指定的長度,會用...替換,不過這段代碼不支援中英文的區分 //if a string is longer than the defined length, //it will add 3 periods to the end of the string.//you can change it to what ever you want for example://return substr($str,0,$len).'[Read More]';

php讀取檔案的範例代碼

這段php代碼詳細示範了如何開啟檔案、讀取檔案和關閉檔案,php中可以通過fopen開啟檔案,通過filesize函數擷取檔案大小,fread讀取檔案內容,fclose關閉檔案 Reading a file using PHP $filename = "/home/user/guest/tmp.txt";$file = fopen( $filename, "r" );if( $file == false ){ echo ( "Error in opening file" );

PHP多檔案上傳實現

只要以數組形式來命名表單中的檔案上傳標記,即可實現多個檔案同時上傳。 下面我們來看一個例子: --------------------------------------------------------------------- function upload($file_error, $file_tmp_name, $file_name){ $info = ""; if($file_name == "") return

php 四捨五入的三種方法

php 四捨五入的三種方法,分別通過number_format函數、round函數和sprintf格式化輸出的方法實現四捨五入 1.number_format 方法實現四捨五入 $number = 1234.5678; $nombre_format_francais = number_format($number, 2, ',', ' '); // 1 234,57 $english_format_number = number_format($number, 2, '.', '');

PHP防SQL注入的一個類

class sqlsafe { private $getfilter = "'|(and|or)\\b.+?(>| private $postfilter = "\\b(and|or)\\b.{1,6}?(=|>| private $cookiefilter = "\\b(and|or)\\b.{1,6}?(=|>| /** * 建構函式 */ public function __construct() { foreach($_GET

總頁數: 5203 1 .... 2469 2470 2471 2472 2473 .... 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.