Time of Update: 2017-01-13
js版匹配中文字元的Regex: [/u4e00-/u9fa5]匹配雙位元組字元(包括漢字在內):[^/x00-/xff] 代碼如下複製代碼 var reg = /^[u4e00-u9fa5]+$/;if(reg.test(str)){ alert('漢字的幹活');}計算字串的長度(一個雙位元組字元長度計2,ASCII字元計1)String.prototype.len=function(){return
Time of Update: 2017-01-13
先看一個php與mysql資料庫的無限分類建立資料庫 :id,fid,fname(id和fid都必需是數字類型而且fid的預設值一定要設成0; 代碼如下複製代碼 <?php$stime=microtime();$db=@mysql_connect("localhost","root","micronsky.net") or
Time of Update: 2017-01-13
功能簡單,直接上代碼。 代碼如下複製代碼 <a href='shortcuts.php'>火星時代IT開發</a> shortcuts.php 代碼 代碼如下複製代碼 $Shortcut = "[InternetShortcut]URL=http://www.111cn.netIDList=IconFile=http://www.111cn.net/favicon.icoProp3=19,2";header(&
Time of Update: 2017-01-13
寫一個函數,將資料 代碼如下複製代碼 $array = array( 0=>array("","河北"), 1=>array("","北京"), 2=>array(0,"保定"),
Time of Update: 2017-01-13
1,年-月-日echo date('Y-m-j');2007-02-6echo date('y-n-j');07-2-6大寫Y表示年四位元字,而小寫y表示年的兩位元字;小寫m表示月份的數字(帶前置),而小寫n則表示不帶前置的月份數字。echo date('Y-M-j');2007-Feb-6echo
Time of Update: 2017-01-13
一,關閉notice錯誤提示1、在php.ini檔案中改動error_reporting改為: 代碼如下複製代碼 error_reporting=E_ALL & ~E_NOTICE 2、如果你不能操作php.ini檔案,你可以使用如下方法在你想禁止notice錯誤提示的頁面中加入如下代碼: 代碼如下複製代碼 error_reporting(E_ALL^E_NOTICE);
Time of Update: 2017-01-13
代碼如下複製代碼 <?php//需要替換的關鍵字$GLOBALS["patterns"] = array( "/#BASE_URL#/");//替換後的內容,和上面的匹配規則一一對應$GLOBALS["replacements"] = array(
Time of Update: 2017-01-13
異常本身的文法並不值得討論,異常的使用情境才是主要的,這裡我對比php和java,來看看php裡的異常到底是怎麼回事,異常到底應該怎麼用。 看到了PPC論壇上的這篇討論,覺得很有價值,我重新整理了下我的觀點,做個總結。
Time of Update: 2017-01-13
資料庫結構 代碼如下複製代碼 -- phpMyAdmin SQL Dump-- version 2.11.2-rc1-- http://www.111cn.net---- 主機: localhost-- 產生日期: 2010 年 11 月 09 日 05:34-- 伺服器版本: 5.0.41-- PHP 版本: 5.2.4SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";---- 資料庫: `demo`---- ----------
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
Codigniter架構使用jquery+ajax/" target="_blank">jquery ajax代碼如下: 代碼如下複製代碼 <form action="<?php echo @htmlspecialchars($url['login_url']) ?>" method="post"
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驗證ip格式的程式碼如果網站有表單需要填寫ip地址,那麼先要驗證格式是否正確。php驗證ip格式是否正確使用Regex來實現,其核心代碼如下: 代碼如下複製代碼 <form action="" method="post"> <input type="text" name="ip"/> <input
Time of Update: 2017-01-13
首先是 Ajax.php檔案:這個檔案我覺著就是接收資料處理資料的 代碼如下複製代碼 <?phpmysql_connect("localhost","root","");mysql_select_db("aaa");mysql_query("set names 'UTF8'"); 上面的這些代碼 不用我說都知道是串連資料庫的 代碼如下複製代碼
Time of Update: 2017-01-13
代碼如下複製代碼
Time of Update: 2017-01-13
因為複選框大多是幾個同時存在的,我們都會name[]的名字必須是一個數組的 這樣只要擷取一個就可以了 代碼如下複製代碼 html代碼<input type="checkbox" name="frm_tag[]" id="frm_tag" value="1">1<input type="checkbox" name="frm_tag[]"
Time of Update: 2017-01-13
substr() 函數返回字串的一部分。文法substr(string,start,length)例子 1 代碼如下複製代碼 <?phpecho substr("Hello world!",6);?>輸出:world! 例子2 代碼如下複製代碼 echo substr('中國文',1);
Time of Update: 2017-01-13
mkdir();函數php建立檔案夾和檔案///建立檔案夾 代碼如下複製代碼 function createdir($dir){if(file_exists($dir) && is_dir($dir)){//如果存在這個檔案並且這個檔案是個目錄就不動作}else{ mkdir($dir,0777);//否則就創造這個目錄}} file_exists();函數file_exists -- 檢查檔案或目錄是否存在
Time of Update: 2017-01-13
如果利用php來判斷就簡單了,原理很簡單:識別是否是動畫,要檢查檔案中是否包含chr(0×21).chr(0xff).chr(0x0b).’NETSCAPE2.0‘chr(0×21).chr(0xff)是gif圖片中擴充功能段的標題‘NETSCAPE2.0‘是擴充功能執行的程式名代碼如下。 代碼如下複製代碼 <?php function IsAnimatedGif($filename)&
Time of Update: 2017-01-13
例 代碼如下複製代碼 <?php$people = array("Peter", "Joe", "Glenn", "Cleveland");if (in_array("Glenn",$people)) { echo "Match found"; }else { echo