Time of Update: 2016-07-25
$Database_name = 'somedb';$table = 'sometable'; Define ('H', 'localhost'); define ('N', 'root') define ('P','password'); define ('T', $database_name); Mysql_connect (H, N, P) or die (mysql_error ()); mysql_select_db (T) or die (mysql_error ()
Time of Update: 2016-07-25
一個功能強大且便於使用的PHP微架構,旨在協助您建立動態和強大的Web應用程式 - 快!整個架構大小不到 60kb,雖然輕量,但不簡單。對路由、ORM、MVC的支援都非常不錯。全功能的工具包只有?55KB的超輕量級程式碼程式庫易於學習,使用和擴充F3 支援包括 SQL 和 NoSQL 資料庫:MySQL, SQLite, MSSQL/Sybase, PostgreSQL, MongoDB 和其自身輕量級快速的 Flat-File DB (稱為
Time of Update: 2016-07-25
/*==================================================================*/ /* 檔案名稱:BaseLogic.class.php */ /* 概要: 資料處理公用類. */ class BaseLogic extends MyDB {
Time of Update: 2016-07-25
$int=36; $str=array(); $flag=0; //echo chr($int%36+87); while($int!=0) { if($int%36 else $str[$flag++]=chr($int%36+87); $int/=36; }
Time of Update: 2016-07-25
//error_reporting(0);//關閉錯誤報表 include_once("simple_html_dom.php");//引入解析庫 $url='http://www.w3cschool.cc/mongodb/mongodb-window-install.html'; $html=file_get_html($url);
Time of Update: 2016-07-25
/* 1.產生隨機數 2.插入表 3.查詢 4.返回yes */ function mak() //產生卡號密碼演算法 可替換; { $str=md5(microtime()); $pass=substr($str,-12); return $pass; } ///////////////產生卡號密碼並存入資料庫$times=你想添加的卡號密碼條數////////
Time of Update: 2016-07-25
/* http認證 判斷來路頁面 寫日誌 */ ////////////禁用錯誤報表////////////// error_reporting(0); ///////////http認證//////////// if(!isset($_SERVER['PHP_AUTH_USER'])) { header('WWW-Authenticate: Basic realm="login:"');
Time of Update: 2016-07-25
/* File name: /include/zip.php Author: Horace 2009/04/15 */ class PHPZip{ var $dirInfo = array("0","0"); var $rootDir = ''; var $datasec = array(); var $ctrl_dir = array(); var $eof_ctrl_dir = "/x50/
Time of Update: 2016-07-25
用在伺服器上提供下載的php代碼,可以指定被下載的檔案名稱,可以動態指定檔案內容 // local file that should be send to the client$local_file = 'test.zip';// filename that the user gets as default$download_file = 'your-download-name.zip'; if(file_exists($local_file) && is_file($local_file))
Time of Update: 2016-07-25
function create_dir($path,$mode) { if (is_dir($path)){ //判斷目錄存在否,存在不建立 echo "目錄'" . $path . "'已經存在"; } else { //不存在建立 $re=mkdir($path,$mode,true);
Time of Update: 2016-07-25
一個php實現的簡單文法高亮顯示的函數,注意:這個函數設計的比較簡單,可能對某些文法不能高亮顯示,你可以自己擴充該函數的功能 function syntax_highlight($code){ // this matches --> "foobar" $code = preg_replace( '/"(.*?)"/U', '"$1"', $code ); // hightlight functions and
Time of Update: 2016-07-25
function copy_dir($src,$dst) { $dir = opendir($src); @mkdir($dst); while(false !== ( $file = readdir($dir)) ) { if (( $file != '.' ) && ( $file != '..' )) { if ( is_dir($src . '/' . $file) ) {
Time of Update: 2016-07-25
PHP表單提交頁面複選框的名稱後要加[],這樣在接收頁面才能得到正確的結果。表單提交後得到的是一個數組,然後通過訪問數組元素得到表單的具體vaule值。得到的checkbox1的值,預設有換行。 表單代碼: 複製代碼 PHP處理表單代碼: if(isset($_POST["Download"])) { foreach($_REQUEST['checkbox1'] as $checkbox1) {
Time of Update: 2016-07-25
function getWeekStartAndEnd ($year,$week=1) { header("Content-type:text/html;charset=utf-8"); date_default_timezone_set("Asia/Shanghai"); $year = (int)$year; $week = (int)$week; //按給定的年份計算本年周總數 $date = new DateTime;
Time of Update: 2016-07-25
這段php代碼可以把一個顏色變成與之相反的顏色編碼,如:白色變成黑色,藍色變成黃色 function color_inverse($color){ $color = str_replace('#', '', $color); if (strlen($color) != 6){ return '000000'; } $rgb = ''; for ($x=0;$x $c = 255 - hexdec(substr($color,(2*$x),2));
Time of Update: 2016-07-25
/** * 截取字串 * params $string 要截取的字串 * params $length: 保留長度(字元數) * params $dot: 多餘部分顯示**/function _cutstr($string, $length, $dot = ' ...') { if(strlen($string) return $string; } $string = str_replace(array('&', '"', ''), array('&',
Time of Update: 2016-07-25
$conn = new Mongo();//可以簡寫為//$conn=new Mongo(); #串連本地主機,預設連接埠.//$conn=new Mongo(“172.21.15.69″); #串連遠程主機//$conn=new Mongo(“xiaocai.loc:10086″); #串連指定連接埠遠程主機//$conn=new Mongo(“xiaocai.loc”,array(“replicaSet”=>true)); #負載平衡//$conn=new
Time of Update: 2016-07-25
/*********************************************************************************** 使用說明: $m= new SendM('smtp伺服器位址','帳號','密碼',連接埠(int),逾時重試時間(int)); $m->Send('收件者郵箱 ','主題','郵件內文內容'); 使用範例: $m= new
Time of Update: 2016-07-25
/** * +-------------------------------------------------------------------- * Description 遞迴刪除目錄 +-------------------------------------------------------------------- * @param string $dir 需要刪除的目錄 +----------------------------------------------------
Time of Update: 2016-07-25
include("class.phpmailer.php");$mail = new PHPMailer();$mail->From = 'your email address@.com';$mail->FromName = 'HTML Blog';$mail->Host = 'host name';$mail->Mailer = 'smtp';$mail->Subject = 'subject';$mail->IsHTML(true);$body = 'HelloHow are you ?';