Time of Update: 2016-07-25
本文介紹下,有關php中可變函數參數的兩個函數,分別是func_num_args與func_get_args函數,有需要的朋友參考下。首先來看func_num_args函數。功能:返回傳遞到函數的參數數目文法:int func_num_args (void )。說明:返回傳遞到目前定義函數的參數數目。如果是從函數定義的外面來呼叫此函數,則func_get_arg( )將會產生警告。func_num_args( )可以用來結合func_get_arg( )和func_get_args(
Time of Update: 2016-07-25
setcookie('php_cn_ck','php_中文_cookie'); setcookie('php_en_ck','php_english_cookie'); ?> PHP cookie已經設定:php_cn_ck=php_中文_cookie、php_en_ck=php_english_cookie。JS cookie已經設定:js_cn_ck=js_中文_cookie、js_en_ck=js_english_cookie。讀取cookie
Time of Update: 2016-07-25
本文分享一個簡單的php使用者登入代碼,通過將使用者名稱與密碼與儲存在數組中的值進行比對,檢測是否有效。有需要的朋友可以作個參考。首先,將使用者名稱與密碼儲存在數組中,當有使用者登入時,從數組中取值參與檢測,以判斷使用者名稱與密碼是否有效。登入與檢測在同一個檔案LoginFormAction中,代碼:"pass1", "name2" =>"pass2"); if ($password ==
Time of Update: 2016-07-25
本文介紹下,php中用於緩衝控制的函數ob_start()的用法,有需要的朋友參考下吧。在php中,ob_start()函數用於開啟緩衝區,比如header()函數之前如果就有輸出,包括斷行符號/空格/換行/都會有"Header had all ready send
Time of Update: 2016-07-25
//序列化數組$test = array("a"=>0,"b"=>0,"c"=>0);$test2 = '';$test2=serialize($test);echo $test2;echo "";print_r(unserialize($test2));複製代碼2,PHP序列化數組用途:主要是處理數組傳遞,數組存庫操作。例如,有一個數組需要傳遞給下一個頁面,如果不想使用seesion/cookie,則可以使用以上函數序列化之後進行傳遞,然後還原。例如,如果做一個網址目錄的程式,其中有個 評分,
Time of Update: 2016-07-25
本文介紹下,在php編程中對檔案進行寫操作的步驟,有需要的朋友,可以參學習下。在php中,寫入檔案一般要經過如下的步驟:1、首先,確定要寫入檔案的內容 $content = ‘你好’;2、然後,開啟檔案(系統會自動建立這個空檔案)//假設建立的檔案叫file.txt,而且在上級目錄下。w表示‘寫檔案’,$fp下面要用到,表示指向某個開啟的檔案。$fp = fopen(’../file.txt’, ‘w’);3、將內容字串寫入檔案
Time of Update: 2016-07-25
在php編程中,使用者登入經常會用到,這裡分享一個不錯的php使用者登入類,有需要的朋友參考下。php使用者登入類,代碼:errReport($this->err_mysql); $this->err=$this->err_mysql; } } function isLoggedin() //判斷是否登入 { if(isset($_COOKIE['sid'])) //如果cookie中儲存有sid {
Time of Update: 2016-07-25
本文介紹下,一個不錯的php與mysql串連類,php5實現的,有需要的朋友參考下吧。代碼:Connect();}function __destruct(){ $this->Close();}private function Connect(){ //資料庫連接 $this->link=mysql_connect($this->Host,$this->UserName,$this->Password) or die("Error Connect to DB");
Time of Update: 2016-07-25
echo $_SERVER['SCRIPT_FILENAME'].''; echo __FILE__;複製代碼執行a.php 得到: require 'a.php';複製代碼執行b.php,結果為: E:/var/www/b.php ($_SERVER['SCRIPT_FILENAME'])E:\wamp\www\Text\a.php (__FILE__)由此,我們得出二者的區別:$_SERVER['SCRIPT_FILENAME'] 當前執行程式的絕對路徑及檔案名稱__FILE__
Time of Update: 2016-07-25
本文介紹下,用php擷取網頁內容的四種方法,包括xmlhttp方法、file_get_contents方法、fopen方法、curl方法。有需要的朋友參考下。1,使用xmlhttp對象,類似asp中的ActiveXObject對象。代碼:open("GET","http://localhost/xxx.php?id=2",false); $xhr->send(); echo
Time of Update: 2016-07-25
本文收集了php中有關image映像操作的一些函數,有簡要說明,有需要的朋友,可以參考下。php image映像函數集,如下:
Time of Update: 2016-07-25
function createTagCloud($tags) { //I pass through an array of tags $i=0; foreach($tags as $tag) { $id = $tag['id']; //the tag id, passed through $name = $tag['tag']; //the tag name, also passed through in
Time of Update: 2016-07-25
本文介紹下,用php實現寫excel檔案的代碼,包括標題與內容等。有需要的朋友參考下。php寫excel檔案,包括標題。這在日常的開發中經常用到,比如一些連絡人名單、公司通訊錄的操作,都會用到php操作excel檔案的功能。代碼:setActiveSheetIndex(0); //設定活動頁面 $activeSheet = $objPHPExcel->getActiveSheet(); //擷取當前活動頁面
Time of Update: 2016-07-25
本文匯總了一些php session相關的函數,有簡要說明,有需要的朋友,可以收藏下,以備不時之需。php
Time of Update: 2016-07-25
本文介紹下,php實現的擷取遠程網頁內容的幾個方法,包括fopen、curl方式,有需要的朋友參考下吧。分享幾段擷取遠程網頁內容的php代碼。1、fopen方式如果出現:failed to open stream: HTTP request failed!錯誤。解決方案:在php.ini中,有這樣兩個選項:allow_url_fopen =on(表示可以通過url開啟遠程檔案),user_agent="PHP"(表示通過哪種指令碼訪問網路,預設前面有個 " ; " 去掉即可。)重啟伺服器。 如:
Time of Update: 2016-07-25
複製代碼2,upload_file.php //php普通檔案上傳//by bbs.it-home.orgif ((($_FILES["file"]["type"] == "image/gif")|| ($_FILES["file"]["type"] == "image/jpeg")|| ($_FILES["file"]["type"] == "image/pjpeg"))&& ($_FILES["file"]["size"] if ($_FILES["file"]["error"] > 0
Time of Update: 2016-07-25
if (isset($_REQUEST['GLOBALS']) OR isset($_FILES['GLOBALS'])) { exit('Request tainting attempted.');}複製代碼register_globals 是php中的一個控制選項,可以設定成off或者on ,預設為off,決定是否將 EGPCS(Environment,GET,POST,Cookie,Server)變數註冊為全域變數。如果 register_globals開啟的話,
Time of Update: 2016-07-25
分享一個php cookie操作類,用到了php中的命名空間,這個比較新穎,有需要的朋友參考下吧。一個php cookie操作類,實現了基本的操作功能:建立cookie、設定cookie的到期時間、登出cookie等。代碼:name = (string) $name)){if(!is_null($value)){$this->value = (string) $value;$this->expire = $expire;$this->path = $path;$this->domain =
Time of Update: 2016-07-25
/*** whois資訊查詢* by bbs.it-home.org*/function ae_whois($query, $server){ define('AE_WHOIS_TIMEOUT', 15); // connection timeout global $ae_whois_errno, $ae_whois_errstr; // connecting $f = fsockopen($server, 43, $ae_whois_errno, $ae_whois_
Time of Update: 2016-07-25
本文分享一個php 驗證類的代碼,可用於驗證Email地址、驗證是否數字、驗證日期等。有需要的朋友不妨作個參考。php 驗證類的代碼,如下:0 && ($D2,php 驗證類的調用樣本:is_email($_POST['email'])) echo "Email is Valid!"; else echo "Not a valid email"; echo ""; if($val->is_number($_POST['number'])) echo "number is