Time of Update: 2017-01-19
本文執行個體講述了php採集中國Proxy 伺服器網的方法。分享給大家供大家參考。具體如下:<?php/** * 採集中國Proxy 伺服器網 最新列表 */class proxy{ /* 需採集列表 */ public $list; /* 代理列表 儲存路徑 */ public $save_path = 'proxy.txt'; /* 擷取採集列表 */ function get_list($page) { $url =
Time of Update: 2017-01-19
先貼張圖看看效果在貼一下代碼吧<?php $localhost = "localhost"; $username = "root"; $password = "root"; $db = "test"; //資訊 $pagesize = 5; $conn = mysql_connect($localhost,$username,$password); //連結資料庫 if(!$conn){ echo "資料庫連結失敗".mysql_error(); }
Time of Update: 2017-01-19
本文執行個體講述了PHP產生plist資料的方法。分享給大家供大家參考。具體如下:這段代碼實現PHP數群組轉換為蘋果plist XML或文字格式設定<?PHP/** * PropertyList class * Implements writing Apple Property List (.plist) XML and text files from an array. * * @author Jesus A. Alvarez
Time of Update: 2017-01-19
本文執行個體講述了php動態綁定變數的用法。分享給大家供大家參考。具體如下:private function bindVars($stmt,$params) { if ($params != null) { $types = ''; //initial sting with types foreach($params as $param) { //for each element, determine type and add if(is_int($param)) {
Time of Update: 2017-01-19
本文執行個體講述了php實現在伺服器端調整圖片大小的方法。分享給大家供大家參考。具體分析如下:在伺服器端完成圖片大小的調整,會比在瀏覽器的處理有很多的好處。 本文介紹了PHP如何在伺服器端調整圖片大小。程式碼封裝括兩部分:① imageResizer() is used to process the image② loadimage() inserts the image url in a simpler format<?php function
Time of Update: 2017-01-19
本文執行個體講述了PHP正則驗證Email的方法。分享給大家供大家參考。具體如下:<?phpfunction validateEmail($email){ $isValid = true; $atIndex = strrpos($email, "@"); if (is_bool($atIndex) && !$atIndex) { $isValid = false; } else { $domain = substr($email, $atIndex+1); $local =
Time of Update: 2017-01-19
本文執行個體講述了PHP實現通過Regex替換回調的內容標籤。分享給大家供大家參考。具體實現方法如下:function my_wp_plugin_tag_action($content,$tag,$function,$args = FALSE) { // match all regular expressions preg_match_all($tag,$content,$matches); if (count($matches)>0) { // filter duplicates $
Time of Update: 2017-01-19
本文執行個體講述了PHP檢測使用者語言的方法。分享給大家供大家參考。具體如下:function getPreferredLanguage() { $langs = array(); if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) { // break up string into pieces (languages and q factors) preg_match_all('/([a-z]{1,8}(-[a-z]{1,8})?)\s*(;\
Time of Update: 2017-01-19
本文執行個體講述了php實現求相對時間函數。分享給大家供大家參考。具體實現方法如下:<?phpfunction relativeTime($time = false, $limit = 86400, $format = 'g:i A M jS') { if (empty($time) || (!is_string($time) & amp; & amp; !is_numeric($time))) $time = time(); elseif (is_string($time)
Time of Update: 2017-01-19
本文執行個體講述了php數組隨機排序實現方法。分享給大家供大家參考。具體實現方法如下:<?php $array = array('A','2','3','4','5','6','7','8','9','10','J','Q','K'); shuffle($array); //隨機排序數組 print_r($array); //輸出數組 ?>運行結果如下:Array( [0] => Q [1] => 3 [2] => 5 [3] => 2
Time of Update: 2017-01-19
本文執行個體講述了PHP擷取數組的鍵與值方法。分享給大家供大家參考。具體如下:使用數組的過程中經常要遍曆數組。通常需要遍曆數組並獲得各個鍵或值(或者同時獲得鍵和值),所以毫不奇怪,PHP為此提供了一些函數來滿足需求。許多函數能完成兩項任務,不僅能擷取當前指標位置的鍵或值,還能將指標移向下一個適當的位置。擷取當前數組鍵 key()key()函數返回input_array中當前指標所在位置的鍵。其形式如下:mixed key(array
Time of Update: 2017-01-19
以前看一些PHP架構源碼的時候,很奇怪在檔案包含的時候,會用dirname(__FILE__)來拼湊檔案路徑,不知道這樣做有什麼好處,後來終於發現了其中的緣由。我們來看一個簡單的例子:有a,b,c三個php檔案。a.php在網站根目錄,b.php在b檔案夾下——b/b.php,c.php在c檔案夾下——c/c.php。有些混亂?看圖就一目瞭然了:a.php 和 b.php 都包含了 c.php,最後 c.php 包含了d檔案夾下的一個php檔案——d/d.php。我們先來看a.php:<&
Time of Update: 2017-01-19
本文執行個體講述了PHP尋找與搜尋數組元素方法。分享給大家供大家參考。具體分析如下:尋找、篩選與搜尋數組元素是數組操作的一些常見功能。下面來介紹一下幾個相關的函數。in_array()函數in_array()函數在一個數組匯總搜尋一個特定值,如果找到這個值返回true,否則返回false。其形式如下:boolean in_array(mixed needle,array haystack[,boolean
Time of Update: 2017-01-19
本文執行個體講述了php使用array_search函數實現數組尋找的方法。分享給大家供大家參考。具體實現方法如下:<?php$array = array(4,5,7,8,9,10); $found = array_search(8, $array);//調用array_search函數並輸出尋找結果 if($found) //如果找到輸出鍵 echo "已找到,鍵為".$found; else //如果沒有找到輸出錯誤資訊 echo "沒有找到";
Time of Update: 2017-01-19
本文執行個體講述了php線性表的入棧與出棧用法。分享給大家供大家參考。具體如下:<?php $stack = array("Simon", "Elaine"); //定義數組 array_push($stack, "Helen", "Peter"); //入棧 print_r($stack); ?><?php $stack = array("Simon", "Elaine"); //定義數組 array_unshift ($stack, "Helen",
Time of Update: 2017-01-19
本文執行個體講述了php數組合并與拆分的方法。分享給大家供大家參考。具體如下:<?php $array1 = array("A","B","C","D"); $array2 = array("1","2","3","4"); $array3 = array("!","@","#","$"); $arrayX = array_merge($array1, $array2, $array3);//將3個數組合并起來 print_r($arrayX); ?> <
Time of Update: 2017-01-19
問題說明: 有時需要在兩個或三個資料庫的表中,通過相關關鍵字,查詢擷取所需記錄集,用一般的SQL查詢語句是實現不了的,可通過ACCESS的跨庫查詢功能實現。 解決方案: 例如“裝材類型”和“裝材”兩張表是在不同的資料庫中的,具體查詢方法,如下:複製代碼 代碼如下:@"Select * from 裝材類型 as a INNER JOIN [;database=" AppDomain.CurrentDomain.BaseDirectory "裝材.zc].裝材 as b ON
Time of Update: 2017-01-19
本文執行個體講述了php簡單smarty入門程式。分享給大家供大家參考。具體如下:首先要有3個檔案夾configs、templates、templates_c,在configs檔案夾中有一個設定檔:test.conf,代碼:title = Welcome to Smarty!cutoff_size = 40[setup]bold = truetemplates中有模板檔案:test.htm:<html> <head> <title>Smarty
Time of Update: 2017-01-19
簡單整理一下PHP項目整合PayPal支付功能。一、表單的構建:<form method="post" name="form" action="https://www.paypal.com/cgi-bin/webscr"><input type="hidden" name="rm" value="2"/><input type="hidden" name="cmd" value="_xclick"/><input type="hidden" name="
Time of Update: 2017-01-19
本文執行個體講述了php使用GD庫建立圖片縮圖的方法。分享給大家供大家參考。具體分析如下:上傳頁面的靜態html代碼:<html> <head> <title>檔案上傳</title> <meta http-equiv="Content-Type" content="text/html; charset=gb2312"> </head> <H1>檔案上傳</H1> <form enctype="