Time of Update: 2017-01-13
在用PHP進行浮點數的運算中,遇到一個坑,沒有得到預期中的結果,如下代碼:$a = 69.1; $b = $a*100; $c = $b-6910;你猜$c的值是多少?$c輸出的值是-9.0949470177293E-13.為什麼會這樣?在PHP官網Float浮點型頁面中,講到:浮點數的精度浮點數的精度有限。儘管取決於系統,PHP 通常使用 IEEE 754 雙精確度格式,則由於取整而導致的最大相對誤差為
Time of Update: 2017-01-13
由於項目需求,需要安裝php5.3的環境,而windows下的WAMPServer安裝時使用的是php5.5,不同版本下的一些函數會有些許差別,多版本php就必不可少了。下面是安裝PHP5.3,PHP5.4,PHP5.5的步驟:wamp安裝不贅述了,由於系統是64位的,下載php版本的時候最好也下64位的。方案一:1.首先到http://windows.php.net/download/下載
Time of Update: 2017-01-13
代碼如下複製代碼 <!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-
Time of Update: 2017-01-13
文法feof(file)參數 描述 file 必需。規定要檢查的開啟檔案。說明file 參數是一個檔案指標。這個檔案指標必須有效,並且必須指向一個由 fopen() 或 fsockopen() 成功開啟(但還沒有被 fclose() 關閉)的檔案。 代碼如下複製代碼 <?php教程 // if file can not be read or doesn't exist fopen function returns false $file = @fopen(&
Time of Update: 2017-01-13
代碼如下複製代碼 <?phpclass listdir{var $depth;var $dirname;var $list;var $tostring;function listdir($dir){$this->dirname=$dir;$this->depth=0;$this->tostring=”";}//把結果儲存進多維陣列function
Time of Update: 2017-01-13
例1 代碼如下複製代碼 function get_user_browser() { if (empty($_SERVER['HTTP_USER_AGENT'])) { return ''; } $agent = $_SERVER['HTTP_USER_AGENT']; $browser = ''; $browser_ver = ''; if (preg_match('/MSIEs([^s|;]+
Time of Update: 2017-01-13
利用for迴圈把我們定義好的字元遍曆即可 代碼如下複製代碼 <?php/* Generate Password* Length : 8*/$str = “0123456789abcdefghijklmnopqrstuvwxyz”; // 輸出字元集$n = 8; // 輸出串長度$len = strlen($str)-1;for($i=0 ;
Time of Update: 2017-01-13
代碼如下複製代碼 var http_request=false; function send_request(url){//初始化,指定處理函數,發送請求的函數http_request=false;//開始初始化XMLHttpRequest對象if(window.XMLHttpRequest){//Mozilla瀏覽器 http_request=new
Time of Update: 2017-01-13
最簡單的辦法就是直接使用php $_SERVER['HTTP_REFERER']如果我在A.php頁面要登入現在跳到B.php頁面,我們只要在b.php中加如下代碼 代碼如下複製代碼 $url = $_SERVER['HTTP_REFERER'];header("location:$url");
Time of Update: 2017-01-13
PHP中的類
Time of Update: 2017-01-13
string strip_tags ( string str [, string allowable_tags] )弊端 :這個函數只能保留想要的html標籤,就是參數string allowable_tags。在yizero的評論中我知道了這個函數的參數allowable_tags的其他的用法。 代碼如下複製代碼 strip_tags($source, ”); 去掉所以的html標籤。strip_tags($source, ‘<div>&
Time of Update: 2017-01-13
for迴圈遍曆二維數組 代碼如下複製代碼 print_r($order_data_info);Array([0] => stdClass Object ( [countOrder] => 3 [amntTotal] => 2380.00 [name] => 測試版 )[1] => stdClass Object ( [countOrder] => 1 [amntTotal] => 2380.00 [name] => VIP版 )
Time of Update: 2017-01-13
使用 PHP 向頁面 POST 資料 代碼如下複製代碼 <?phpfunction socketPost($url, $data, &$ret){ $urlArr = parse_url($url); $host = $urlArr['host']; $port = isset($urlArr['port'])?$urlArr['port']:80; $path =
Time of Update: 2017-01-13
這是最簡單的了 代碼如下複製代碼 <?php header("Content-type:application/vnd.ms-excel");header("Content-Disposition:attachment;filename=test_data.xls");$tx=’表頭’; echo $tx."nn";
Time of Update: 2017-01-13
代碼如下複製代碼 /** * CURL請求 * @param String $url 請求地址 * @param Array $data 請求資料 */ function curlRequest($url,$data='',$cookieFile=''){ $ch = curl_init(); $option = array( CURLOPT_URL => $url, CURLOPT_HEADER =>0, CURLOPT_RETURNTRANSFER =>
Time of Update: 2017-01-13
代碼如下複製代碼 <?php /* author: ssh_kobe date: 20110602 shortage: 如果網頁中的圖片路徑不是絕對路徑,就無法抓取 */ set_time_limit(0);//抓取不受時間限制$URL='http://pp.baidu.com/';//任意網址get_pic($URL);function get_pic($pic_url) { //擷取圖片二進位流 $data=CurlGet($pic_url);
Time of Update: 2017-01-13
php closedir 函數closedir(PHP 4中,PHP 5中)closedir - 關閉目錄控制代碼報告錯誤描述無效closedir([資源$ dir_handle指定])關閉目錄流dir_handle指定。該流必須是曾開幕opendir()。報告錯誤參數dir_handle指定處理資源的目錄以前與opendir()開啟。如果目錄控制代碼沒有指定,最後一個環節由opendir()開啟假設。看個執行個體<?php$dir = "/etc/php5/";//
Time of Update: 2017-01-13
php loop continue執行的代碼塊中指定的次數,或在指定的條件為真。-------------------------------------------------- ------------------------------對於迴圈迴圈使用的是當你事Crowdsourced Security Testing道多少次的指令碼應該運行。文法for (init; condition; increment) { code to be executed;
Time of Update: 2017-01-13
目錄 1. 什麼是異常 2. d 入門 3. 自訂異常 4. 多個異常 5. 重新拋出異常 6. 程式流的異常 7. 頂層例外處理常式 8. 錯誤碼 9. 摘要 什麼是例外。.隨著PHP
Time of Update: 2017-01-13
例子<?php/** * * Read a line number from a file * * @param string $file The path to the file * @param int $line_num