Time of Update: 2016-07-25
echo '本周第一天(星期日為一周開始):'.date('Y-m-d', time()-86400*date('w')).'';echo '本周第一天(星期一為一周開始):'.date('Y-m-d', time()-86400*date('w')+(date('w')>0?86400:-6*86400)).'';echo '本月第一天:'.date('Y-m-d', mktime(0,0,0,date('n'),1,date('Y'))).'';echo '本月最後一天:'.date('Y-
Time of Update: 2016-07-25
分享一個截取指定長度字串的函數,可以對字串指定要截取的長度,並可以設定超出部分的顯示內容,很不錯,值得借鑒與學習。根據中文裁減字串,截取指定長度的字串內容。代碼如下:'),array($pre . '&'. $end, $pre . '"' . $end, $pre . '' . $end), $string); $strcut = ''; if (strtolower(CHARSET) == 'utf-8'){ $n = $tn =$noc = 0; while
Time of Update: 2016-07-25
本文介紹下,在php編程中,關閉已開啟的檔案的方法,有需要的朋友參考下。在php中,當開啟檔案進行相關操作以後,需要及時的對檔案控制代碼進行關閉,以避免較長時間的資源佔用。php 關閉檔案在php編程中,當用完一個檔案之後,一定要及時的關閉,這是一個良好的習慣。php
Time of Update: 2016-07-25
本文分享下,一段可類比撲克牌玩法的php代碼,有需要的朋友參考下。php 撲克牌代碼,如下:cut();* www: jbxue.com*/class cards{/**** Declare our deck variable **/private $deck;/**** Constructor.. duh!**/function __construct(){ /*** set the deck array variable ***/ $this->deck=$this->setDeck()
Time of Update: 2016-07-25
本文介紹下,php中用於中文字元截取的一個函數,有需要的朋友參考下。分享一個自己一直在用的PHP中文字元截取函數,很不錯,有用到的朋友拿去吧。代碼:<?php/*** @ 中文字元截取* @ site:bbs.it-home.org*/function str_cut($string, $length, $dot = ”) {if(strlen($string) <= $length) { return $string;}$strcut = ”;for($i = 0; $i
Time of Update: 2016-07-25
本文收集了一些php中有關stream資料流的函數集,有需要的朋友,可以參考下。php stream函數集,如下:
Time of Update: 2016-07-25
本文介紹下,使用php代碼擷取目錄的md5序列值的方法,分享一段代碼,供有需要的朋友參考下。PHP 擷取目錄的 md5 序列值。代碼:read())) { if ($entry != '.' && $entry != '..' && $entry != '.svn') { if (is_dir($dir.'/'.$entry)) { $filemd5s[] = md5_folder($dir.'/'.$entry); } else { $filemd5s[] =
Time of Update: 2016-07-25
echo $_SERVER['SCRIPT_FILENAME'].''; echo __FILE__;複製代碼執行a.php 得到: require 'a.php';複製代碼執行b.php,結果為: E:/var/www/b.php ($_SERVER['SCRIPT_FILENAME'])E:\wamp\www\Text\a.php (__FILE__)由此,我們得出二者的區別:$_SERVER['SCRIPT_FILENAME'] 當前執行程式的絕對路徑及檔案名稱__FILE__
Time of Update: 2016-07-25
本文介紹下,用php擷取網頁內容的四種方法,包括xmlhttp方法、file_get_contents方法、fopen方法、curl方法。有需要的朋友參考下。1,使用xmlhttp對象,類似asp中的ActiveXObject對象。代碼:open("GET","http://localhost/xxx.php?id=2",false); $xhr->send(); echo
Time of Update: 2016-07-25
function createTagCloud($tags) { //I pass through an array of tags $i=0; foreach($tags as $tag) { $id = $tag['id']; //the tag id, passed through $name = $tag['tag']; //the tag name, also passed through in
Time of Update: 2016-07-25
分享一個php使用者認證的代碼,基於資料庫儲存的資訊進行使用者認證,有需要的朋友參考下吧。php實現使用者認證的一例代碼,大家參考下。代碼:
Time of Update: 2016-07-25
if (isset($_REQUEST['GLOBALS']) OR isset($_FILES['GLOBALS'])) { exit('Request tainting attempted.');}複製代碼register_globals 是php中的一個控制選項,可以設定成off或者on ,預設為off,決定是否將 EGPCS(Environment,GET,POST,Cookie,Server)變數註冊為全域變數。如果 register_globals開啟的話,
Time of Update: 2016-07-25
//php擷取今日開始時間戳和結束時間戳記$beginToday=mktime(0,0,0,date('m'),date('d'),date('Y'));$endToday=mktime(0,0,0,date('m'),date('d')+1,date('Y'))-1;//php擷取昨日起始時間戳記和結束時間戳記$beginYesterday=mktime(0,0,0,date('m'),date('d')-1,date('Y'));$endYesterday=mktime(0,0,0,date
Time of Update: 2016-07-25
/* Copyright 2009 Dominic Sayers (dominic_sayers@hotmail.com) (http://www.dominicsayers.com)This source file is subject to the Common Public Attribution License Version 1.0 (CPAL) license. The license terms are available through the world-wide-web
Time of Update: 2016-07-25
複製代碼2,php代碼部分$x = $_REQUEST['x'];$y = $_REQUEST['y'];$format = $_REQUEST['format'];$site = $_REQUEST['site'];$surl = 'http://jbxue.com/screenshot_it.php?site='.$site.'&x='.$x.'&y='.$y.'&format='.$format;if($_REQUEST['format'] == 'PNG') {$ifm = 'png';
Time of Update: 2016-07-25
/*** 取得youku視頻的最終地址* edit by bbs.it-home.org* at: 2013-10-2*/class YoukuFlv{ static private $error = ""; static private $result = array(); static public function getYoukuFlv($url){ //從url擷取youkuid if(! $id = self:
Time of Update: 2016-07-25
$lines = file('http://bbs.it-home.org/');foreach ($lines as $line_num => $line) {echo "Line {$line_num} : " . htmlspecialchars($line) . "\n";}?>複製代碼2,擷取網頁的標題: $url = 'http://bbs.it-home.org';$lines_array = file($url);echo $lines_array;echo "";$lines_
Time of Update: 2016-07-25
本文分享一個簡單的php、mysql操作類,很簡單,主要是資料的串連、查詢等。有需要的朋友參考下吧。分享一段php、mysql操作類的代碼,供初學的朋友參考。一個簡單的類使用php和mysql資料庫連接類,代碼:db_connect($db_host, $db_user, $db_pass,$db_name); $query="insert db_user values('$username','$password')";
Time of Update: 2016-07-25
本文分享一個不錯的php 驗證碼類,後面附有完整的調用樣本,有需要的朋友,參考下吧。1,php驗證碼類 session_name = $name ; $this-> image_width = $width ; $this-> image_height = $height ; $this-> cod_length = $length ; $this-> mode = $mod ; $this-> font_path = $font
Time of Update: 2016-07-25
本文介紹下,在php中實現隊列queue資料結構的一例代碼,是學習隊列操作的不錯的例子,有需要的朋友參考下吧。什麼是隊列?隊列(Queue),是一種特殊的先進先出線性表,其只能在前端進行刪除操作(一般稱為出隊),在後端進行插入操作(一般稱為入隊)。進行刪除操作的端稱為隊頭,進行插入操作的端稱為隊尾。隊列,是按照先進先出或後進後出的原則組織資料。當隊列中沒有元素時,稱為空白隊列。下面分享下,php實現的資料結構與演算法- 隊列(Queue)的代碼。如下:queue = array();