php實現編輯和儲存檔案的方法

本文執行個體講述了php實現編輯和儲存檔案的方法。分享給大家供大家參考。具體如下:save_file.php:session_start(); $handle = fopen($_POST['original_file_name'], "w"); $text = $_POST['file_contents']; if(fwrite($handle, $text) == FALSE){ $_SESSION['error'] = 'There was an error'; }else{ $_

php實現QQ空間擷取目前使用者的使用者名稱並產生圖片

本文執行個體講述了php實現QQ空間擷取目前使用者的使用者名稱並產生圖片的方法。分享給大家供大家參考。具體如下:最近發現空間裡經常會轉載一些含有目前使用者暱稱和qq號的圖片,很好奇,研究了一下原理原理很簡單,圖片是利用php產生的,好吧,直接上代碼圖片原始碼:$ment = $_SERVER["HTTP_REFERER"];if($ment == 'http://cnc.qzs.qq.com/qzone/newblog/v5/editor.html'){ header("HTTP/1.0 50

發送郵件的PHP類

class emailui{ static function runlog($mode = 'SMTP',$b = '',$c = '',$d='') { } static function sendmail($toemail, $subject, $message, $from='',$cfg = array(), $sitename='') { global $db_wwwname,$mail_port,$mail_id,$mail_server,$mail_pw,$mail_

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擷取圖片詳細資料(寬 高 格式 大小)

function getImageInfo($img) //$img為影像檔絕對路徑{ $img_info = getimagesize($img); switch ($img_info[2]) { case 1: $imgtype = "GIF"; break; case 2: $imgtype = "JPG"; break; case 3:

長微博產生工具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檔案裡的bom代碼

if (isset($_GET['dir'])) { //設定檔案目錄 $basedir = $_GET['dir'];} else { $basedir = '.';}$auto = 1;checkdir($basedir);function checkdir($basedir){ if ($dh = opendir($basedir)) { while (($file = readdir($dh)) !== false) { if

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類

/* * Author 墨龍 * Time 2010年12月2日 15:50:35 */ $db = new mysql($db_host,$db_user,$db_password,$db_table,$db_conn,$pre,$coding); class mysql{ private $db_host; private $db_user; private

PHP操作Cookie的類

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

一個PHP分頁函數

PHP分頁代碼調用: $start=show_page($query,$page,$link,$offset);其中: $start為起始記錄 $query為全記錄檢索SQL語句 $page為當前頁碼 $link為傳遞的頁面參數 $offset為每頁顯示記錄數 //======function.php=====//======分頁函數==========function show_page($query,$page,$link,$offset){ $db = new mysql();

完整的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判斷來訪者是否是搜尋引擎的爬蟲

我們可以通過HTTP_USER_AGENT來判斷是否是蜘蛛,搜尋引擎的蜘蛛都有自己的獨特標誌,下面列取了一部分。 function is_crawler() { $userAgent = strtolower($_SERVER['HTTP_USER_AGENT']); $spiders = array( 'Googlebot', // Google 爬蟲 'Baiduspider', // 百度爬蟲 'Yahoo! Slurp', //

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 四捨五入的三種方法

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 .... 1682 1683 1684 1685 1686 .... 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.