Time of Update: 2016-07-25
cd /etc/yum.repos.d/ cp CentOS-Base.repo CentOS-Base.repo.bak複製代碼1.2替換源 用vi開啟CentOS-Base.repo,並將內容清空,然後將下面的內容複寫進去,並儲存。 yum -y update複製代碼2. 用yum安裝Apache,Mysql,PHP.2.1安裝Apache yum install httpd httpd-devel 複製代碼安裝完成後,用/etc/init.d/httpd start
Time of Update: 2016-07-25
使用Regex進行尋找替換 首先需要聲明的是,其實我對正則的應用也不是特別地熟練,只不過是在工作中“被逼無奈”才一步步地對正則有了一些瞭解。隨著對正則的瞭解越多,越來越發現Regex真的是一個很強有力的工具,使用正則,很多時候都可以事半功倍。 網上流傳著很多通用的正則,比如說尋找電話號碼的正則,尋找email的正則。相信也有很多朋友跟我一樣,學習正則是從這些流行的正則開始的,當體會到了正則的強大,而這些流行的正則不再合用時,就有了學習正則的動力。其實正則的基本規則很簡單,入門很容易,
Time of Update: 2016-07-25
// function with 2 optional argumentsfunction foo($arg1 = '', $arg2 = '') { echo "arg1: $arg1\n"; echo "arg2: $arg2\n";}foo('hello','world');/* prints:arg1: helloarg2: world*/foo();/* prints:arg1:arg2:*/複製代碼如何建立能夠接受任何參數數目的函數。需要使用 func_get_args() 函數:
Time of Update: 2016-07-25
介紹下php中is_file與file_exists的區別,is_file 只判斷檔案是否存在;file_exists 判斷檔案是否存在或者是目錄是否存在;分享下php中is_file與file_exists的區別,供大家參考。is_file 只判斷檔案是否存在;file_exists 判斷檔案是否存在或者是目錄是否存在;is_dir
Time of Update: 2016-07-25
set_time_limit(13600); //設定時間$conn=mysql_connect('localhost','root',''); //串連資料庫mysql_select_db('csdn',$conn);mysql_query("SET NAMES utf8");$file=file('csdn.txt');foreach($file as $line){ $u=explode('# ', $line); mysql_query("INSERT INTO
Time of Update: 2016-07-25
phpRegex完全教程五,phpRegex的部分例子phpRegex的部分例子Regex 說明/b([a-z]+) 1b/gi 一個單詞連續出現的位置/(w+)://([^/:]+)(:d*)?([^# ]*)/ 將一個URL解析為協議、域、連接埠及相對路徑/^(?:Chapter|Section) [1-9][0-9]{0,1}$/ 定位章節的位置/[-a-z]/ A至z共26個字母再加一個-號。/terb/ 可匹配chapter,而不能terminal/Bapt/
Time of Update: 2016-07-25
class Model{ protected $tableName="";//表名稱 protected $pOb;//pdo類對象 function __construct(){ $pdo=new PDO("mysql:host=".DB_HOST.";dbname=".DB_NAME,DB_USERNAME,DB_PASSWORD); $pdo->exec("set names ".DB_CHARSET); $this->pOb=$pdo; } /* * 作用:增 * 參數:array
Time of Update: 2016-07-25
max_execution_time = 30 ; Maximum execution time of each script, in secondsmax_input_time = 60 ; Maximum amount of time each script may spend parsing request data;max_input_nesting_level = 64 ; Maximum input variable nesting levelmemory_limit
Time of Update: 2016-07-25
var_dump(in_array(0, array('s' )); 複製代碼結果:bool(true)。因為in_array會將0 和's' 進行比較,0是number類型,'s'是string類型,根據php manual 中“Comparison Operators” 一章的說明可知,number 和string進行比較時,會先將string類型首先轉化為number,然後再進行比較操作。's'轉化為number的結果為0,而0 == 0 的結果是true,所以in_array(0,
Time of Update: 2016-07-25
/*** 圖片加浮水印(適用於png/jpg/gif格式)* * @author flynetcn** @param $srcImg 原圖片* @param $waterImg 浮水印圖片* @param $savepath 儲存路徑* @param $savename 儲存名字* @param $positon 浮水印位置 * 1:頂部居左, 2:頂部居右, 3:置中, 4:底部局左, 5:底部居右 * @param $alpha 透明度 -- 0:完全透明, 100:完全不透明* *
Time of Update: 2016-07-25
echo memory_get_usage(), ''; // 313864$tmp = str_repeat('http://www.nowamagic.net/', 4000);echo memory_get_usage(), ''; // 406048unset($tmp);echo memory_get_usage(); // 313952?> 複製代碼上面的程式後面的注釋代表了它們的輸出(單位為 byte(s)),也就是當時 PHP 指令碼使用的記憶體(不含
Time of Update: 2016-07-25
教你如何開啟php檔案 在回答這個問題之前,我們先來瞭解什麼是php。 PHP,是英文超級文本預先處理語言Hypertext Preprocessor的縮寫。PHP 是一種 HTML 內嵌式的語言,是一種在伺服器端執行的嵌入HTML文檔的指令碼語言,語言的風格有類似於C語言,被廣泛的運用。
Time of Update: 2016-07-25
$dst_path = 'dst.jpg';//建立圖片的執行個體$dst = imagecreatefromstring(file_get_contents($dst_path));//打上文字$font = './simsun.ttc';//字型$black = imagecolorallocate($dst, 0x00, 0x00, 0x00);//字型顏色imagefttext($dst, 13, 0, 20, 20, $black, $font, '快樂編程');//輸出圖片list(
Time of Update: 2016-07-25
//1、建立畫布$im = imagecreatetruecolor(300,200);//建立一個真彩色映像,預設背景是黑色,返回映像標識符。另外還有一個函數 imagecreate 已經不推薦使用。$red = imagecolorallocate($im,255,0,0);//2、寫字$str = "hello,world";imagestring($im,5,30,60,$str,$red);//參數說明:5-指文字的大小。函數 imagestring
Time of Update: 2016-07-25
$outfile=shell_exec("/usr/bin/varnishstat -x");$xml=simplexml_load_string($outfile);echo $xml->getName() . "";foreach($xml->children() as $child){//$tmpName="";foreach($child->children() as $subChild){if ($subChild->getName() =="name" )
Time of Update: 2016-07-25
class DemoSubject implements SplSubject{ private $observers, $value; public function __construct(){ $this->observers = array(); } public function attach(SplObserver $observer){ $this->observers[] = $observer; }
Time of Update: 2016-07-25
function debug($var, $val){echo "***DEBUGGING\nVARIABLE: $var\nVALUE:";if (is_array($val) || is_object($val) || is_resource($val)) {print_r($val);} else {echo "\n$val\n";}echo "***\n";}$c = mysql_connect();$host =
Time of Update: 2016-07-25
//------------------------------------- // 檔案說明:檔案上傳處理類 // 檔案作者:Jesse Lee // 作者首頁:http://bbs.it-home.org // 最後更新:2011-5-14 //------------------------------------- class upload { var $dir; //附件存放物理目錄 var $time;
Time of Update: 2016-07-25
//1、建立畫布$im = imagecreatetruecolor(300,200);//建立一個真彩色映像,預設背景是黑色,返回映像標識符。另外還有一個函數 imagecreate 已經不推薦使用。//2、繪製所需要的映像$red =
Time of Update: 2016-07-25
class A{ public $name; function test1($a){ echo "test1111"; } function test2($a){ echo "test2222"; } //當某個對象調用某個方法,而當該方法不存在時,則系統會自動調用__call() function __call($method,$val){ echo "類中找不到方法:".$method; }}$aaa = new A();$aaa ->test(1);?> 複製代碼輸出結果:類中找不到方法: