Time of Update: 2016-07-25
?$str="this is a test \n";$patten = array("\r\n", "\n", "\r");?//先替換掉\r\n,然後是否存在\n,最後替換\r$str=str_replace($order, "", $str);?>複製代碼//php 有三種方法來解決//1、使用str_replace 來替換換行$str = str_replace(array("\r\n", "\r", "\n"), "", $str);//2、使用正則替換$str =
Time of Update: 2016-07-25
/*** 壓縮html : 清除分行符號,清除定位字元,去掉注釋標記* @param $string* @return 壓縮後的$string* from: bbs.it-home.org* */function compress_html($string) {$string = str_replace("\r\n", '', $string); //清除分行符號$string = str_replace("\n", '', $string); //清除分行符號$string =
Time of Update: 2016-07-25
/**------------------------Function: php2html($in_Url, $out_htmlFile, $out_logFile)------------------------@ Description: 產生靜態函數@ Copyright: Copyright (c) 2006 - 2011@ Create: 2006-08-01@ Modify: 2013-02-16@ 提示:路徑為伺服器絕對路徑; 若給定的路徑目錄不存在則自動建立@
Time of Update: 2016-07-25
/** 功能:產生靜態頁面 整理:指令碼學堂 bbs.it-home.org 日期:2013-2-16*/class html{var $dir; //dir for the htmls(without/)var $rootdir; //root of html files(without/):htmlvar $name; //html檔案存放路徑var $dirname; //指定的檔案夾名稱var $url; //擷取html檔案資訊的來源網頁地址var $time;
Time of Update: 2016-07-25
// 擷取檔案的當前路徑 + 檔案名稱echo __FILE__;echo '';// 擷取檔案的當前路徑echo dirname(__FILE__);echo '';// 擷取檔案的上一級目錄路徑echo
Time of Update: 2016-07-25
$content=str_replace("\n","",$content);echo $content;複製代碼方法二: str_replace("\r\n","",$str);複製代碼方法三: $content=preg_replace("/\s/","",$content);echo $content;複製代碼附文-----:\n 軟斷行符號:在Windows 中表示換行且回到下一行的最開始位置在Linux、unix 中只表示換行,但不會回到下一行的開始位置。\r
Time of Update: 2016-07-25
ob_start();@readfile("http://bbs.it-home.org/");$text = ob_get_flush();$myfile = fopen("myfile.html","w");$text =str_replace
Time of Update: 2016-07-25
Create TABLE `bihtml` (`id` int(11) NOT NULL auto_increment,`szdtitle` varchar(16) NOT NULL,`szdcontent` text NOT NULL,PRIMARY KEY (`id`)) TYPE複製代碼擷取當前的ID,並匯入模板: ob_start();$id=_POST['id']if(!isset($id)&is_integer($id)){@$db=new
Time of Update: 2016-07-25
php的require()與include(),在效能方面並無大的不同。僅有的一些不同在於:include()執行時檔案每次都要進行讀取和評估;require()執行時檔案只處理一次(實際上,檔案內容替換了require()語句)。php的require()與include(),在效能方面並無大的不同。僅有的一些不同在於:include()執行時檔案每次都要進行讀取和評估;require()執行時檔案只處理一次(實際上,檔案內容替換了require()語句)。即如果有包含這些指令之一的代碼和可能
Time of Update: 2016-07-25
class Crypt3Des{private $key = "";private $iv = "";/*** 構造,傳遞二個已經進行base64_encode的KEY與IV** @param string $key* @param string $iv*/function __construct ($key, $iv){if (empty($key) || empty($iv)) {echo 'key and iv is not valid';exit();}$this->key =
Time of Update: 2016-07-25
{ title }this is a { file } file's templets 複製代碼PHP處理: templetest.php $title = "測試模板";$file = "TwoMax Inter test templet,author:Matrix@Two_Max"; $fp = fopen ("temp.html","r");$content = fread ($fp,filesize ("temp.html"));$content .= str_replace ("{
Time of Update: 2016-07-25
ob_start();#開啟伺服器緩衝include_once 'Index.php';$ctx=ob_get_contents();#擷取緩衝ob_end_clean();#清空緩衝$fh=fopen("index.html","w+");fwrite($fh,$ctx);#寫入html,產生htmlfclose($fh);?>複製代碼方法2:php 靜態檔案產生類 class CreateHtml{function mkdir( $prefix= 'article' ){$y = date(
Time of Update: 2016-07-25
class SingetonBasic {private static $instance;// other vars..private function __construct() {// do construct..}private function __clone() {}public static function getInstance() {if (!(self::$instance instanceof self)) {self::$instance = new
Time of Update: 2016-07-25
本文是php-redis中文文檔的第一部分,主要介紹redis官方提供的一些命令的提示,有需要的朋友可以參考下。本文是php-redis中文文檔的第一部分,主要介紹redis官方提供的一些命令的提示,有需要的朋友可以參考下。phpredis作為php的一個擴充,效率很高,有鏈表排序功能,對建立記憶體級的模組業務關係很有用;下載地址:https://github.com/owlient/phpredis(支援redis 2.0.4)以下是redis官方提供的命令提示:
Time of Update: 2016-07-25
include_once 'include/Base.php';$path = '';$url = isBase::decrypt(urlDecode($_SERVER['QUERY_STRING']));parse_str($url); //擷取通過url地址GET傳遞過來的變數if(!empty($_POST['path'])){ //擷取POST傳遞過來的變數$path = $_POST['path'];$path = isBase::decrypt(urlDecode($path));}
Time of Update: 2016-07-25
本文是php-redis中文文檔的第四部分,有需要的朋友可以參考下。本文是php-redis中文文檔的第四部分,有需要的朋友可以參考下。getRange (方法不存在)返回名稱為key的string中start至end之間的字元$redis->set('key', 'string value');$redis->getRange('key', 0, 5);$redis->getRange('key', -5, -1); setRange
Time of Update: 2016-07-25
/* func: get_client_ip() 擷取用戶端IP地址*/function get_client_ip(){ $ip=false; if(!empty($_SERVER["HTTP_CLIENT_IP"])) { $ip = $_SERVER["HTTP_CLIENT_IP"]; } if (!empty($_SERVER['HTTP_X_FORWARDED_FOR']))
Time of Update: 2016-07-25
$con = file_get_contents("http://bbs.it-home.org/wzjs/");$pattern="//";$new_con = preg_replace($pattern,"$0",$con);echo $new_con;?> 複製代碼說明:$0表示這個匹配內容,$1表示第一個()匹配的內容
Time of Update: 2016-07-25
注意:ob_flush()和flush()這兩個函數一般要一起使用,順序是先ob_flush(),然後flush(),它們的作用是重新整理緩衝區。這裡具體的說下什麼時候要用到重新整理緩衝區和為什麼要重新整理緩衝區。注意:ob_flush()和flush()這兩個函數一般要一起使用,順序是先ob_flush(),然後flush(),它們的作用是重新整理緩衝區。這裡具體的說下什麼時候要用到重新整理緩衝區和為什麼要重新整理緩衝區。一、什麼時候要重新整理緩衝區當程式中用到file_get_content
Time of Update: 2016-07-25
/*** 自動載入相關類庫檔案*/function __autoload($classname){if(substr($classname,-6)=="Action"){include APP_PATH.'controllers/'.$classname.'.class.php';}elseif(substr($classname, -5)=="Model"){include