Time of Update: 2016-07-25
// 注意在 4.0.0-RC2 之前不存在 !== 運算子if ($handle = opendir('/path/to/files')) { echo "Directory handle: $handle\n"; echo "Files:\n"; while (false !== ($file = readdir($handle))) { echo "$file\n"; } while ($file =
Time of Update: 2016-07-25
php數組去除空值的小函數,php遞迴函式刪除數組中值為空白的元素,一起學習下。代碼: /** * 方法庫-數組去除空值 * @param string $num 數值 * @return string */public function array_remove_empty(&$arr, $trim = true) { if (!is_array($arr)) return false; foreach($arr as $key => $value){ if
Time of Update: 2016-07-25
function resizeImage($im,$maxwidth,$maxheight,$name,$filetype) { $pic_width = imagesx($im); $pic_height = imagesy($im); if(($maxwidth && $pic_width > $maxwidth) || ($maxheight && $pic_height > $maxheight)) { if($maxwidth &&
Time of Update: 2016-07-25
php數組的定義與數組遍曆,php數組函數的用法與例子,php數組取值賦值,php多維陣列的迴圈輸出等,供大家學習參考。1、php數組定義和遍曆 2、php數組函數1、數組定義: $arr=array(1,2,3);//索引數組,下標全是數字$arr=array("name"=>"user1","age"=>"30");//關聯陣列,下標中包含字母//下標只有兩種,要麼是字母,要是是不帶雙引號的數字1,3,"age"=>4,5,100=>6,7,400=>8,9); echo "";
Time of Update: 2016-07-25
// pdo $pdo = new pdo("mysql:host=localhost;dbname=database", 'username', 'password');// mysqli, 面向過程方式$mysqli = mysqli_connect('localhost','username','password','database');// mysqli, 物件導向$mysqli = new
Time of Update: 2016-07-25
imagecolorsforindex()imagecolorat()在圖片上畫圖形 $img=imagecreatefromgif("./images/map.gif");/*** 圖片銳利化處理* edit by bbs.it-home.org*/$red= imagecolorallocate($img, 255, 0, 0);imageline($img, 0, 0, 100, 100, $red);imageellipse($img, 200, 100, 100, 100, $red)
Time of Update: 2016-07-25
Response.Buffer = True Response.ExpiresAbsolute = Now() - 1 Response.Expires = 0 Response.CacheControl = "no-cache" Response.AddHeader "Pragma", "No-Cache"複製代碼2、在html代碼中加入 複製代碼3、在重新調用原頁面的時候在給頁面傳一個參數 Href="****.asp?
Time of Update: 2016-07-25
$a = 'hello';function test() {var_dump($a);}// test();include 'b.inc';複製代碼b.inc內容: echo 'hello';?> 複製代碼該程式能夠正常輸出hello,但是被注釋掉的test()不能正常解析,因為變數$a是未定義的。4、使用全域變數若在某個函數中想使用全域變數,可以通過下面兩種方式。global關鍵字global $a,
Time of Update: 2016-07-25
$sub = "bbs.it-home.org"; $ptn = '/\w*\.\w*\.\w*/'; // Regex,中繼資料,返回的資料 preg_match($ptn, $sub,$mats); echo ""; print_r($mats); echo ""; ?> //匹配ip$str = "my ip is 192.168.10.1sdjlfajdf192.178.39.4la"; $ptn = '/\d+\.\d+\.\d+\.\d+/';
Time of Update: 2016-07-25
$dbh = new PDO('mysql:host=localhost;dbname=access_control', 'root', ''); $dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $dbh->exec('set names utf8'); /*添加*///$sql = "INSERT INTO `user` SET `login`=:login AND `password`=:password";
Time of Update: 2016-07-25
$str="http://bbs.it-home.org/junzaivip"; $arr = pathinfo($str); echo ""; print_r($arr); echo ""; ?> //將一個網域名稱拆分為數組$str="http://bbs.it-home.org/junzaivip.php?id=10&name=20"; $arr = parse_url($str); $query = $arr['query']; $arr2 =
Time of Update: 2016-07-25
$image = new Imagick('logo.jpg');$im = new Imagick();$im->newImage( 140, 80, new ImagickPixel( "none" ) ); $draw = new ImagickDraw();$draw->setFillColor(new ImagickPixel( "grey" ));$draw->setGravity(imagick::GRAVITY_NORTHWEST);$draw->annotation(10,10
Time of Update: 2016-07-25
//php ob函數庫抓取遠程圖片function GetImage($url, $filename = "") {if ($url == "") {return false;}if ($filename == "") {$ext = strrchr ( $url, "." );if ($ext != ".gif" && $ext != ".jpg") {return false;}$filename = time () . $ext;}//檔案 儲存路徑ob_start
Time of Update: 2016-07-25
mysql_connect("localhost", "root","1981427") //串連位於localhost的伺服器,使用者名稱為root ?>複製代碼串連再選擇資料庫 @mysql_select_db("test") //選擇資料庫mydb?> 複製代碼這樣就可以實現串連到資料庫了運行代碼出現:call to undefined function 'mysql_connect()'… 失敗這個提示function
Time of Update: 2016-07-25
//設定phpexcel類庫的include pathset_include_path('.'. PATH_SEPARATOR . 'D:\Zeal\PHP_LIBS' . PATH_SEPARATOR . get_include_path());/** * 以下是使用樣本,對於以 //// 開頭的行是不同的可選方式,請根據實際需要 * 開啟對應行的注釋。 * 如果使用 Excel5 ,輸出的內容應該是GBK編碼。
Time of Update: 2016-07-25
/** 1、擷取路徑的檔案名稱* string basename(string path[,string suffix])* 2、擷取路徑的目錄* string dirname(string path)* 3、瞭解更多的路徑資訊* array pathinfo(string path)* 4、確定絕對路徑* string realpath(string path)* 5、確定檔案的大小* int filesize(string filename)* 6、計算磁碟的可用空間* float
Time of Update: 2016-07-25
$str="指令碼學堂:http://bbs.it-home.org";function mbstringtoarray($str,$charset) { $strlen=mb_strlen($str); while($strlen){ $array[]=mb_substr($str,0,1,$charset); $str=mb_substr($str,1,$strlen,$charset); $strlen=mb_strlen($str);
Time of Update: 2016-07-25
error_reporting(E_ALL); date_default_timezone_set('Asia/ShangHai'); /** PHPExcel_IOFactory */require_once '../Classes/PHPExcel/IOFactory.php'; // Check prerequisitesif (!file_exists("31excel5.xls")) { exit("not found 31excel5.xls.\n");} $reader =
Time of Update: 2016-07-25
/*** 頁面名稱:page_class.php*/class Page {private $each_disNums; //每頁顯示的條目數private $nums; //總條目數private $current_page; //當前被選中的頁private $sub_pages; //每次顯示的頁數private $pageNums; //總頁數private $page_array = array (); //用來構造分頁的數組private $subPage_link;
Time of Update: 2016-07-25
php數組current和next的用法,二個例子,方便大家理解current和next的使用方法。php數組current和next的用法1、current取php數組當前值 2、next取php數組下一個值