Time of Update: 2016-07-25
/*** Author : GuoWangYunYan* QQ : 279861795* Date : 2011-6-23* link:www.jbuxe.com*///設定編碼header('Content-type: text/html; charset=utf-8');//比較變態的用了個五維數組$a = array( 'AAAAAA' => array( 'aaaaaa' => array( '111111',
Time of Update: 2016-07-25
/** desc:數組合并 link:bbs.it-home.org date:2013/2/22*/$a = array( 'a' => 1, 'b' => 2 );$b = array( 'b' => 3, 'd' => 4 );//數組合并$array_merge = array_merge( $a, $b );echo '';print_r( $array_merge );//數組遞迴合并$array_merge_recursive = array_merge_recursive(
Time of Update: 2016-07-25
/**desc:數組遞迴求和link:bbs.it-home.orgdate:2013/2/22*/function arraySumRecursive($array){ $total = 0; foreach(new recursiveIteratorIterator( new recursiveArrayIterator($array)) as $num) { $total += $num; } return $total;}/*** a flat array
Time of Update: 2016-07-25
$file = 'jbxue.com.php';if (is_readable($file) == false) {die('檔案不存在或者無法讀取');} else {echo '存在';}?>複製代碼is_readable() 函數判斷指定檔案名稱是否可讀.指定的檔案或目錄存在並且可讀,則返回 TRUE例2: $filename = 'jbxue.com.php';if (file_exists($filename)) {echo "The file $filename exists";}
Time of Update: 2016-07-25
[Date]; Defines the default timezone used by the date functions;date.timezone =複製代碼預設是關閉的,只需把注釋去掉,改為即可 [Date]; Defines the default timezone used by the date functionsdate.timezone =
Time of Update: 2016-07-25
/** php資料流應用 date:2013/2/19*/$count = 5; start: if($count echo "Put Password: "; $handle = fopen ("php://stdin","r"); $line = fgets($handle); if(trim($line) != '123456'){ $count--; if(!$count) goto error; goto start; } goto success; error: echo
Time of Update: 2016-07-25
/*** 遞迴 無限級分類 返回數組* link:bbs.it-home.org* date:2013/2/21*/$conn = mysql_connect('localhost','root','123456');mysql_select_db('test');mysql_query("set names 'utf8'");function getCate($pid = 0){$sql = "select * from cate where pid=".$pid;$res =
Time of Update: 2016-07-25
php中的數組有一維數組、二維數組和多維陣列。一維數組的遍曆很簡單,一個for迴圈即可實現。對於二維數組、多維陣列的遍曆,則需要下點功夫了。這裡為大家舉一個多維陣列遞迴遍曆的例子,供大家參考。運行結果:Array( [1] => Array ( [0] => 11 [1] => 12 [2] => 13 [14] => Array ( [0] => 141 [1]
Time of Update: 2016-07-25
/** desc:檢網路地址格式是否有效 link:bbs.it-home.org date:2013/2/24*/function checkUrl($weburl) { return !ereg("^http(s)*://[_a-zA-Z0-9-]+(.[_a-zA-Z0-9-]+)*$", $weburl); } ?>複製代碼2、判斷http 地址是否有效 /** desc:檢測http 地址是否有效 link:bbs.it-home.org date:2013
Time of Update: 2016-07-25
php中比較常用的特殊運算子號和函數(包括註解符號、常用符號轉義、運算子號、賦值運算子、位元運算、邏輯運算、其它),有需要的朋友可以參考下。php中比較常用的特殊運算子號和函數(包括註解符號、常用符號轉義、運算子號、賦值運算子、位元運算、邏輯運算、其它),有需要的朋友可以參考下。一、註解符號// 單行註解多行註解引號的使用' ' 單引號,簡單字串,不經任何處理直接拿過來;" "雙引號,php動態處理然後輸出,一般用於處理$變數.布爾變數:一種是true 即 真的;另一種是false
Time of Update: 2016-07-25
$xx=我不長,我不長,我不長,我不長,我不長,我不長,我不長,我不長,我不長,我不長,我不長,我不長,我不長,我不長,我不長,?指令碼學堂 http://bbs.it-home.org html;$x='我很長,如何換行呢?我很長,如何換行呢?我很長,如何換行呢?我很長,如何換行呢?我很長,如何換行呢?程式員之家 http://bbs.it-home.org ';echo $xx;?>複製代碼
Time of Update: 2016-07-25
$array = array('abcd','abcde','bcde','cdef','defg','defgh');$str = '~'.implode('~',$array).'~';$word = $_GET['word']; //url = xxx.php?word=apreg_match_all("/~({$word}(?:[^~]*))/i",$str,$matches);var_dump($matches[1]);//輸出//array(2) { [0]=> string(4)
Time of Update: 2016-07-25
echo'hello';echo'world!';?> 複製代碼output:hellloworld!例2: echo'hello\n';//unix系統使用\n;windows系統下\r\necho'world!';?> 複製代碼output:helloworld!通過以上兩個例子,相信你已經理解php中\n、\r\n及的應用場合了吧。您可能感興趣的文章:php fwrite寫入txt檔案 \r\n不能換行的解決方案
Time of Update: 2016-07-25
/**讀取檔案內容至字串中,同時去除換行、行首行尾空格。 */ header("Content-type: text/html; charset=utf-8");echo preg_replace('/((\s)*(\n)+(\s)*)/i',',',file_get_contents('./file.php'));//End_php//輸出://aaaa,bbbb,cccc,dddd,eeee,ffff,gggg,hhhh,iiii,jjjj,kk kk,ll
Time of Update: 2016-07-25
/** desc:設定檔 link:bbs.it-home.org date:2013/2/24*/$name="admin";//kkkk$bb='234';$db=4561321;$kkk="admin";?>複製代碼函數定義:設定檔資料值擷取:function getconfig($file, $ini, $type="string")設定檔資料項目更新:function updateconfig($file, $ini, $value,$type="string")調用方式:
Time of Update: 2016-07-25
header('Content-type: text/css'); ob_start("compress"); function compress($buffer) { /* remove comments */ $buffer = preg_replace('!/\*[^*]*\*+([^/][^*]*\*+)*/!', '', $buffer); /* remove tabs, spaces, newlines,
Time of Update: 2016-07-25
/** desc:採集網頁中的郵箱的代碼 link:bbs.it-home.org date:2013/2/24*/$url='http://bbs.it-home.org'; //這個網頁裡絕對含有郵件地址。$content=file_get_contents($url);//echo $content;function getEmail($str) {//$pattern = "/([a-z0-9]*[-_\.]?[a-z0-9]+)*@([a-z0-9]*[-_]?[a-z0-9]+
Time of Update: 2016-07-25
要將textarea裡的斷行符號換行轉換成br存入資料庫,即轉換textarea中的分行符號的問題,調試了很長時間。1.必須知道textarea中的分行符號是 \n (個人檢測發現按斷行符號鍵是\n,好像在linux下是\r\n)要將textarea裡的斷行符號換行轉換成br存入資料庫,即轉換textarea中的分行符號的問題,調試了很長時間。1.必須知道textarea中的分行符號是 \n
Time of Update: 2016-07-25
echo ''; $b = array(1,1,2,3,5,8); $arr = get_defined_vars(); // 列印 $b print_r($arr["b"]); // 列印所有伺服器變數 print_r($arr["_SERVER"]); // 列印變數數組的所有可用索引值 print_r(array_keys(get_defined_vars())); ?> 複製代碼2. get_defined_functions (PHP 4 >= 4
Time of Update: 2016-07-25
$tmp = 0 == "a"? 1: 2;echo $tmp;?>複製代碼結果 1 int和string類型強制轉換造成的,0==="a"0 == 0 肯定是true啊PHP是弱類型。。$tmp = 0 === "a"? 1: 2;echo $tmp; 這樣就是24. 已知一個字串如下: $str = "1109063 milo 1";用一行代碼將該字串裡面的1109063賦值給$uid, milo賦值給$user, 1賦值給$type空格如下list($uid, $user, $type)