Time of Update: 2016-07-25
檢查日期是否合法日期 function check_date($date) { //檢查日期是否合法日期 $dateArr = explode("-", $date); if (is_numeric($dateArr[0]) && is_numeric($dateArr[1]) && is_numeric($dateArr[2])) {
Time of Update: 2016-07-25
提取頁面和瀏覽器提交的變數,作用相當於使PHP.INI開了全域變數 //提取頁面和瀏覽器提交的變數,作用相當於使PHP.INI開了全域變數 //OSPHP.com.CN @extract($_SERVER, EXTR_SKIP); @extract($_SESSION, EXTR_SKIP); @extract($_POST, EXTR_SKIP); @extract(
Time of Update: 2016-07-25
$start = microtime(true);for($i = 0; $i preg_match('/age=\d+/',$_SERVER['QUERY_STRING']);}$end = microtime(true);?>複製代碼php
Time of Update: 2016-07-25
require 'Net/SMTP.php';$host = '126.com';//smtp伺服器的ip或網域名稱$username= 'arcow';//登陸smtp伺服器的使用者名稱$password= 'secret';//登陸smtp伺服器的密碼$from = 'jbxue@126.com'; //誰發的郵件$rcpt = array('test@test.com', 'jbxue@126.com');//可設多個接收者$subj = "Subject:
Time of Update: 2016-07-25
class FruitQuoteService{ public $__dispatch_map = array(); public $__typedef = array(); public function FruitQuoteService() { $this->__dispatch_map['getQuote'] = array( "in" => array("category" => "string"), "out" =>
Time of Update: 2016-07-25
$post_content = "@oschina和@twitter在研究用#PHP#的#Regex#過濾話題和對象名";$tag_pattern = "/\#([^\#|.]+)\#/";preg_match_all($tag_pattern, $post_content, $tagsarr);$tags = implode(',',$tagsarr[1]);$user_pattern = "/\@([a-zA-z0-9_]+)/";$post_content = preg_replace($
Time of Update: 2016-07-25
delete.php$link=mysql_connect("localhost","root",""); mysql_select_db("dbname"); $id=$_POST['select']; //調用input的nameforeach($id as $ide){ $exec="delete from tablename where sID=$ide"; $result=mysql_query($exec); if((mysql_affected_rows()==0) or
Time of Update: 2016-07-25
利用open flash chart組建圖表 訪問方式: http://127.0.0.1/chart/chart.html?ofc=data.php
Time of Update: 2016-07-25
define('CACHE_ROOT', dirname(__FILE__).'/cache'); //緩衝存放目錄 define('CACHE_TIME', 1800);//緩衝時間 單位秒 define('CACHE_FIX','.html'); $CacheName=md5($_SERVER['REQUEST_URI']).CACHE_FIX; //快取檔案名 $CacheDir=CACHE_ROOT.'/'.substr($CacheName,0,1);/
Time of Update: 2016-07-25
$serverName = "127.0.0.1";$connectionInfo = array( "UID"=>"sa","PWD"=>"","Database"=>"test");$conn = sqlsrv_connect( $serverName, $connectionInfo);if( $conn === false ){ echo "Could not connect.\n"; die( print_r( sqlsrv_errors(),
Time of Update: 2016-07-25
很簡單的一段, 沒啥好說的.. /** * 容量格式化 * * @param Int $filesize * @return
Time of Update: 2016-07-25
遞迴的深度優先的演算法 define('DS', DIRECTORY_SEPARATOR);function rec_list_files($from = '.'){ if(!is_dir($from)) { return array(); } $files = array(); if($dh = opendir($from))
Time of Update: 2016-07-25
根據傳入參數自動產生餅圖。 /* * 產生餅形圖片 */class PieChart { private $center; //餅形中點 private $width; //餅形直徑 private $image; //繪圖物件 function __construct($width,$backcolor =
Time of Update: 2016-07-25
// start at the top of the page since we start a sessionsession_name('mysite_hit_counter');session_start();//$fn = 'hits_counter.txt';$hits = 0;// read current hitsif (($hits = file_get_contents($fn)) === false){$hits = 0;}// write one more hitif
Time of Update: 2016-07-25
#!/usr/local/php53/bin/php/*** @params array=rs_array*/#define(MAX,1000);$MAX = 1000;$from = 2;$rs_array= array();echo $MAX."以內的素數...\n";while($from $is_susu=true; foreach($rs_array as $vals){if ((sqrt($from)+1) % $vals == 0 ){ $is_susu=
Time of Update: 2016-07-25
if (isset($_GET["value"])) { $value = $_GET["value"]; } else { $value = false; } if (is_numeric($value) && ($value >= 15 && $value // run my code } else { // handle the issue }複製代碼這是一個非常基本的例子,我們已經寫更多的行,我想看到??的。首先,因為我們不能確定設定的$
Time of Update: 2016-07-25
/*************************************參數說明:$max_file_size : 上傳檔案大小限制, 單位BYTE$destination_folder : 上傳檔案路徑$watermark : 是否附加浮水印(1為加浮水印,其他為不加浮水印);使用說明:1. 將PHP.INI檔案裡面的"extension=php_gd2.dll"一行前面的;號去掉,因為我們要用到GD庫;2. 將extension_dir =改為你的php_gd2.dll所在目錄;****
Time of Update: 2016-07-25
header("Content-Type:text/html; charset=utf-8");define('APP_ROOT', str_replace('\\', '/', dirname(__FILE__)));$test = '中文測試代碼!';function get_tags_arr($title){require(APP_ROOT.'/pscws4.class.php');$pscws = new
Time of Update: 2016-07-25
function base62($x){ $show = ''; while($x > 0) { $s = $x % 62; if ($s > 35) { $s = chr($s+61); } elseif ($s > 9 && $s $s = chr($s + 55); } $show .= $s; $x = floor($x/6
Time of Update: 2016-07-25
unlink()函數使用執行個體//使用unlink函數刪除檔案$filename="data.txt"; //定義變數unlink($filename); //用unlink函數刪除檔案,這裡的filename應該是相對的地址,也就是說將當前網頁目錄下的data.txt刪除掉。如果成功則返回 TRUE,失敗則返回