Time of Update: 2017-01-13
不過使用它首先得有phpGD庫支援。 代碼如下複製代碼 <?php//填充圖表的參數$ChartDiameter = 60; //圖表直徑$ChartData = array(30,70);//用於組建圖表的資料,可通過資料庫來取得來確定也可以多個不過和顏色數組對應//把角度轉換為弧度function radians($degrees){return($degrees*(pi()/180.0));}//取得在圓心為(0,0)圓上
Time of Update: 2017-01-13
今天要做一個專門用於處理搜尋檔案的功能,而搜尋的檔案可能是位於某個目錄下的,尋找目錄下是否存在該目錄,PHP函數當中好像沒有專門這樣的搜尋函數。檔案的操作在 php 中是不可缺少的,而檔案的使用頻率也是非常高的,比如我們常見的目錄管理系統,無資料庫留言本等,都用到了檔案的操作,而這裡的檔案指的不僅僅是目錄的操作,還有指定檔案的操作,比如 txt 檔案等。下面是一個專門用於檔案搜尋的函數方法,file_search 是方法名,後面有三個參數,$directory 是要搜尋的檔案所在的目錄,比如 &
Time of Update: 2017-01-13
我們先假設需要這樣一個擴充,提供一個叫tao_string的函數,他的主要作用是返回一段字元。對應的PHP代碼可能是這樣: 代碼如下複製代碼 function tao_string($str){$result = $str;return $result;} 第一步,產生代碼PHP為了擴充開發的方便,提供了一個類似代碼產生器的工具ext_skel,具體可以參見php.net官方的說明
Time of Update: 2017-01-13
想用一下APC緩衝到底效果如何,無奈在windows找不到相應版本的php-apc.dll擴充檔案,只好在linux下安裝了,不用源碼方式安裝,直接yum就行了:首先要安裝apc的依賴包: 代碼如下複製代碼 yum install php-pear php-devel httpd-devel pcre-devel gcc make 然後使用pecl安裝apc: 代碼如下複製代碼 pecl install apc 添加apc擴充到設定檔:
Time of Update: 2017-01-13
驗證配置 代碼如下複製代碼 define("TOKEN", "xxx");//改成自己的TOKENdefine('APP_ID', 'xxxx');//改成自己的APPID define('APP_SECRET', 'xxx');//改成自己的APPSECRET$wechatObj = new wechatCallbackapiTest();if (isset($_GET['echostr'])) {
Time of Update: 2017-01-13
代碼如下複製代碼 /**************************** * 擷取目錄下的所有檔案 * [$dir] 檔案夾路徑 ****************************/ function deepScanDir($dir) { $
Time of Update: 2017-01-13
本代碼是在thinkphp中開始使用的1.引入類 代碼如下複製代碼 Vendor('PHPExcel.PHPExcel');//引入擴充類.就是/ Vendor('PHPExcel.PHPExcel.IOFactory'); Vendor('PHPExcel.PHPExcel.Reader.Excel5');&
Time of Update: 2017-01-13
下面看下使用方法: 代碼如下複製代碼 <?php error_reporting(0);//消滅萬惡的php警示提示 //設定郵箱 $options = array('email' => array('email1', 'email2'), 'folder' => './backup/', 'mysql' => array('localhost', 'user', 'password', 'db')); $b = new Backup($
Time of Update: 2017-01-13
果是表裡面沒有ntext欄位,可以用以下代碼: 代碼如下複製代碼 <?php // Connect to MSSQL $link = mssql_connect('KALLESPCSQLEXPRESS', 'sa', 'dsc');if(!$link || !mssql_select_db('php', $link)) { die('Unable to connect or select database!'); }// Do a simple query,
Time of Update: 2017-01-13
最簡單的辦法我們就是直接使用jquery autocomplete方法了,如下在執行個體html中 代碼如下複製代碼 <script src="/js/v2/jquery.input_complete.js" type="text/javascript" ></script><link rel="stylesheet"
Time of Update: 2017-01-13
memcache既可以在linux下使用,也可以在windows系統下使用,當然首推linux系統。至於如何安裝memcache,google一下就什麼都出來了。下面貼一段memcache的使用例子: 代碼如下複製代碼 <?php//串連$mem = new Memcache;$mem->connect("127.0.0.1", 11211) or die ("Could not
Time of Update: 2017-01-13
php smarty foreach 函數**/ $tpl = new Smarty(); $tpl->template_dir = $cfg['path']['template']; $tpl->compile_dir = $cfg['path']['root'] .
Time of Update: 2017-01-13
php smarty 目錄引擎執行個體入門教程require(你的目錄 . 'smarty/libs/Smarty.class.php');/** 模版引擎*/$tpl = new Smarty();$tpl->template_dir = 模板目錄;$tpl->compile_dir =解析目錄 . 'tmp/template_c/';$tpl->debugging
Time of Update: 2017-01-13
<?phpinclude ('template.inc'); //包含模板類 template.inc//建立一個執行個體 $tpl = new Template("template");//讀入三個模板檔案的內容,分別給變數"main", " child_header", " child_footer" $tpl->set_file("main&
Time of Update: 2017-01-13
//方法一$ereg_str[url] = "^[hh]{1}[tt]{2}[pp]{1}://[ww]{3}.[0-9a-za-z][0-9a-za-z-]{0,25}((.[a-za-z]{3,4})|(.[a-za-z]{2})){1,2}$ "; //判斷一個合法的url $pattern = $ereg_str['url']; if(ereg($pattern,$string)) echo
Time of Update: 2017-01-13
當你聲明一個類,你需要列出對象應有的所有變數和所有函數—被稱為屬性和方法。列表1中顯示了一個類的構成. 注意在大括弧({})內你只能聲明變數或者函數。列表2中顯示了如何在一個類中定義三個屬性和兩個方法。 列表1class Name extends Another Class { Access Variable Declaration Access Function Declaration } 列表2//定義一個跟蹤使用者的類 class User { //屬性 public
Time of Update: 2017-01-13
$date1 = "2007-10-25";$date2 = time();echo "$date1 compare to $date2";//2007-10-25 compare to 1189772448 $date1 = "2007-10-25"; $date2 = date("y-m-d",time()); echo "$date1 compare to
Time of Update: 2017-01-13
文章簡單利用foreach for list each while來遍曆數組,包括普通的一維數組與二維數組遍曆方法,下面詳細的介紹了每個函數的使用方法。*/$foreach = array(1,2,3);$array2 = array(array('aa'=>33,'bb'=>22,'www.111cn.net'=>11),array('dd'=>44,'ee'=>55,'ff'=>66));//利用for foreach遍曆一維資料for( $i=0;$i&
Time of Update: 2017-01-13
這裡主要是rsort krsort函數,他是對鍵名進行反序排序了,如果要數組元素值排序用sort就成了,array_multisort這個是對多維陣列排序。*/$array = array(array('www.111cn.net',6,8),array(1,2,6));print_r($array);/*array( [0] => array (
Time of Update: 2017-01-13
代碼如下複製代碼 int preg_match ( string pattern, string subject [, array matches [, int flags]]) 在 subject 字串中搜尋與 pattern 給出的Regex相匹配的內容。如果提供了 matches,則其會被搜尋的結果所填充。$matches[0] 將包含與整個模式比對的文本,$matches[1] 將包含與第一個捕獲的括弧中的子模式所匹配的文本,以此類推。