Time of Update: 2017-01-13
第一種 代碼如下複製代碼 function ($file_name,$pass_type=array('jpg','jpeg','gif','bmp','png')){ $yx_file = $pass_type; $kzm = substr(strrchr($file_name,"."),1); $is_img = in_array(strtolower($kzm),$yx_file); if($is_img){ return true; }else{
Time of Update: 2017-01-13
提供一個讀取的函數: 代碼如下複製代碼 //excel日期轉換函式function excelTime($date, $time = false) { if(function_exists('GregorianToJD')){ if (is_numeric( $date )) { $jd = GregorianToJD( 1, 1, 1970 ); $gregorian =
Time of Update: 2017-01-13
例1PHP代碼: 代碼如下複製代碼 <?php @exec("arp -a",$array); //執行arp -a命令,結果放到數組$array中 echo "<pre>"; print_r($array); //列印擷取的數組 foreach($array as $value) {
Time of Update: 2017-01-13
一個最原始最簡單的iframe上傳例子:前台上傳頁面index.html,主要是一個表單與一個js回呼函數。上傳檔案時,form表單的method、 enctype屬性必須和下面代碼一樣。然後將target的值設為iframe的name,這樣就可以實現無重新整理上傳檔案。 代碼如下複製代碼 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
Time of Update: 2017-01-13
代碼如下複製代碼 /**************************** * 擷取目錄下的所有檔案 * [$dir] 檔案夾路徑 ****************************/ function deepScanDir($dir) { $
Time of Update: 2017-01-13
在PHP中,serialize和json兩種方式對一個對象或數組進行序列化或還原序列化有什麼區別呢?假設一個對象和一個數組:$web = new stdClass;$web->site = 'tantengvip';$web->owner = 'tuntun';$web->age = 5;和$web = array();$web['site'] = 'tantengvip';$web['owner'] = 'tuntun';$web['age'] =
Time of Update: 2017-01-13
在PHP開發的過程中經常需要發送POST請求,POST相比GET要安全很多,而且傳輸的資料量也較大。下面PHP程式員雷雪松就帶大家一起總結下PHP發送POST請求的幾種常用方式,分別使用curl、file_get_content來實現POST請求和傳遞參數。1、curl實現PHP POST請求和傳遞參數。$data=array("username"=>"raykaeso","name"=>"雷雪松");/
Time of Update: 2017-01-13
php過濾html的函數: strip_tags(string) 這樣就可以過濾掉所有的html標籤了。 如果想過濾掉除了<img src="">之外的所有html標籤,則可以這樣寫:strip_tags(string,"<img>");過濾除了<img
Time of Update: 2017-01-13
採集的時候有時候需要過濾掉多餘的標籤屬性,比如 img標籤過濾掉除了src屬性之外的所有屬性例如刪除titile alt等屬性以及一些腳的onclick屬性等。例如過濾除了src之外的所有屬性$str= preg_replace('/\s(?!src)[a-zA-Z]+=[\'\"]{1}[^\'\"]+[\'\"]{1}/iu','
Time of Update: 2017-01-13
只需要在不必PHP許可權的目錄或虛擬機器主機設定段(目錄為<Directory>,虛擬機器主機為<VirualHost>)中加上代碼:php_flag engine off即可。例如 代碼如下複製代碼 <Directory /home/www/images/>php_flag engine off</Directory> 除了上面辦法,不可以使用如下方法在可寫檔案夾的目錄下源碼天空,建一個.htaccess檔案,內容為: &
Time of Update: 2017-01-13
Example 7-21. function {include_php}The load_nav.php file:<?php// load in variables from a mysql db and assign them to the templaterequire_once('database.class.php');$db = new Db();$db->query('select url, name from navigation order by
Time of Update: 2017-01-13
function get_product_tree(){ $sql="select * from ecs_category"; $rs = $GLOBALS['db']->getOne($sql); foreach ($rs AS $row) { $rows['cat_id']=$row['cat_id '];
Time of Update: 2017-01-13
<?php/* @author: zhuyubing@gmail.com */class Template{ var $code; function Template($template){ $
Time of Update: 2017-01-13
最近在寫bbs中,遇上代碼轉換問題。尋找了很久,才得到一個比較完善的解決辦法,可以徹底還原發文者的原文。以下貼出,供大家指正。系統:linux php4 oracle8i以下為引用的內容:<?//--標題,名字等欄位入庫處理(去首尾空格)function trans_string_trim($str) {$str=trim($str);$str=eregi_replace("'","''",$str);$str=stripslashes($str);
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
php 產生條碼<?php function UPCAbarcode($code) { $lw = 2; $hi = 100; $Lencode = array('0001101','0011001','0010011','0111101','0100011',
Time of Update: 2017-01-13
*/$array = explode(',','1101,1102,1103,418,617,712,713,312,313,104,105,106,107,108');if( in_array('8',$array) ){ echo 'a';}else{ echo 'b';}/*定義和用法in_array() 函數在數組中搜尋給定的值。文法in_array(value,array,type)參數 描述 value 必需。規定要在數組搜尋的值。 array
Time of Update: 2017-01-13
ereg_replace -- Regex替換(php教程 3, php 4, php 5)string ereg_replace ( string pattern, string replacement, string string )本函數在 string 中掃描與 pattern 匹配的部分,並將其替換為 replacement。返回替換後的字串。(如果沒有可供替換的匹配項則會返回原字串。)<?php$string = "this is a test";echo
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] 將包含與第一個捕獲的括弧中的子模式所匹配的文本,以此類推。