Time of Update: 2017-01-13
產生PNG縮圖的時候,背景是黑色,今天又寫了一個函數來彌補一下。代碼很簡單,就是imagealphablending($thumb,false);與imagesavealpha($thumb,true);很重要.主要就是把PNG的alpha值儲存,不要丟失而已。 代碼如下複製代碼 <?PHP/* *$sourePic:原圖路徑 * $smallFileName:小圖名稱 * $width:小圖寬 *
Time of Update: 2017-01-13
網上有很多朋友用phpmailer組件發送郵件提示:Could not instantiate mail function.錯誤,解決方案少之用少,原因是伺服器沒有安裝sendmail組件,使用yum進行安裝:yum install sendmail/etc/init.d/sendmail start 注意:如果sendmail啟動緩慢,請將hostname加入到/etc/hosts裡面
Time of Update: 2017-01-13
然後隨即產生一個0到最大數之間的一個數,通過迴圈查看它屬於那個區間,返回該區間的key。 代碼如下複製代碼 $prize = array( 1 => 3.5, //3.5%機率 2 => 2.5, 3 => 6, 4 => 2, 5 => 42, //42%機率 6 => 36, 7 => 2, 8 => 4,
Time of Update: 2017-01-13
雖說最新的 PHP 5.4 已經良好支援 JSON 中文編碼,即通過 JSON_UNESCAPED_UNICODE 參數,例如:json_encode("中文", JSON_UNESCAPED_UNICODE)對於早前 PHP 版本,處理不轉義中文字元的 json 編碼PHP 和 JavaScript 互動其實很方便,PHP 原生也提供了對 JSON 格式的支援。主要包括 JSON 編碼和解碼兩個函數:json_endoce:
Time of Update: 2017-01-13
例子評論表情使用的標籤<emt>1</emt>至<emt>60</emt>。對應的圖片路徑/Public/images/face/1.gif至/Public/images/face/60.gif。實現方法是使用preg_replace函數完成評論表情的顯示。<?php$message='文章寫的太好了<emt>3</emt><emt>34</emt>';$message=preg_replace
Time of Update: 2017-01-13
1.添加擴充包 代碼如下複製代碼 php_memcache.dll2.在PHP.INI添加 代碼如下複製代碼 extension=php_memcache.dll3.程式 代碼如下複製代碼 <?php//建立一個mem對象執行個體$mem=new Memcache; if(!$mem->connect("10.18.110.213",11211)){ die(
Time of Update: 2017-01-13
一、htmlentities() 和htmlspecialchars()1、htmlentities()1.1 功能:把字元轉換為 HTML 實體。字元包括ASCII實體和ISO 8859-1實體(HTML實體對照表:http://www.w3school.com.cn/tags/html_ref_entities.html)1.2 文法:htmlentities(string,quotestyle,character-set)1.3
Time of Update: 2017-01-13
首先我們來建立搜尋資料表create table if not exists `search` ( `id` int(4) not null auto_increment, `keyword` varchar(500) not null, primary key (`id`)) engine=myisam default charset=utf8 auto_increment=1 ;儲存資料 代碼如下複製代碼 insert
Time of Update: 2017-01-13
$login = "root";$passwd = "mysql教程";try{ $db=new pdo('mysql:host=localhost;dbname=mysql',$login,$passwd); foreach($db->query('select * from test') as $row){ print_r($row); }
Time of Update: 2017-01-13
分成3個類別1.緩衝模組 這這個是在伺服器上做的緩衝設定,比如Zend公司的Cache產品等,主要原理是通過對PHP代碼檔案的一次編譯儲存在記憶體中,通過減少I/O的操作來加快訪問速度,不在本文討論範圍之列2.HTML方式 或許你說PHP產生HTML的方式不在本文討論的範圍之列,但是我個人人為這種方式仍然是一種Cache方式,如現在流行的產生HTML的程式也有不少,比如國內的一些CMS,這個也不在本文討論的範圍之列,一筆帶過.3.產生Cache檔案
Time of Update: 2017-01-13
一,十進位(decimal system)轉換函式說明1,十進位轉二進位 decbin() 函數,如下執行個體 代碼如下複製代碼 echo decbin(12); //輸出 1100 echo decbin(26); //輸出 11010 decbin (PHP 3, PHP 4, PHP 5)decbin -- 十進位轉換為二進位說明string decbin ( int number )返回一字串,包含有給定 number
Time of Update: 2017-01-13
1>錯誤提示 代碼如下複製代碼 Warning: Cannot send session cookie - headers already sentWarning: Cannot send session cache limiter - headers already sent
Time of Update: 2017-01-13
在程式初始時,遇到錯誤為:PHP Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /var/www/developer/pp1/8-22.php教程 on line 5, referer: http://localhost/developer/pp1/form_input.html,在網上檢查了一下,
Time of Update: 2017-01-13
php教程 字串編碼轉換的常用幾種方法mb_convert_encoding()PHP的內碼轉換函式版本(PHP 4 >= 4.0.6, PHP 5)這個函數可以將各種編碼互相轉換做一個GBK To UTF-8 < ?php header("content-Type: text/html; charset=Utf-8"); echo mb_convert_encoding("你是我的友仔", "UTF-8",
Time of Update: 2017-01-13
經過一時間的 php + mssql,感覺 mssql 對編碼的支援不是很好(其實還是自己沒有把握好啦),但是又還沒有來得急換資料庫,只能將就點,今天又在提交資料時出現了錯誤。由於提交的 ntext 欄位的內容比較多,大約有 220 KB,所以造成了我的誤解,以為是文章太長而引起的錯誤。我一看 php 配置,發現 php 對 mssql.textsize 的支援已經在 400 K了,怎麼還出錯?開啟錯誤後才發現,原來不是文章太長,而是編碼引起的錯誤。錯誤如下:
Time of Update: 2017-01-13
1. output handler ‘ob_gzhandler’ conflicts with ‘zlib output compression’PHP Warning: ob_start() [ref.outcontrol]: output handler ‘ob_gzhandler’ conflicts with ‘zlib output compression’ in yourfilesTry
Time of Update: 2017-01-13
假設有如下三個檔案, c.php a.php b.php 對應的存放目錄為:localhost/ localhost/ localhost/demo 代碼如下複製代碼 c.phprequire_once("a.php");require_once("demo/b.php");B::demo();a.phpclass A{} b.php的內容比較有意思,因為它自己要繼承 CLASS A 所以自己把a.php也引入進去了
Time of Update: 2017-01-13
代碼如下複製代碼 include("cn.php"); //資料庫連接類,這裡不說了自己去找找吧。$Db = new Db();$sql ="select * from 表名 where isnew=1";$query = $Db->query( $sql );$rs = $Db->fetch( $query ,0);$i=10000;foreach( $rs as $v => $vv ){ if(
Time of Update: 2017-01-13
今天怎麼就配置不起來,PHP配置上就提示在頁面上提示 Service
Time of Update: 2017-01-13
安裝 FreeTDSFreeTDS 是 Linux/Unix 下一組軟體開發包,用於實現微軟 SQL Server 和 Sybase 的 Tabular DataStream protocol 協議。利用 FreeTDS 可在 Linux/Unix 下串連 SQL Server 和 Sybase 資料庫。可前往FreeTDS官網看詳細介紹。下載並安裝 FreeTDS進入Linux伺服器,通過如下命令直接下載到伺服器進行安裝,以 freetds-0.95.92.tar.gz 為例。# 下載