Time of Update: 2016-07-28
10個整數,從小到大排序,輸出排序結果$aray = array(5,4,3,2,6,7,9,8,1,10); for($i=0;$i$aray);$i++){ for($j=$i+1;$j$aray);$j++){ $a=$aray[$i]; $b=$aray[$j]; if($a>$b){ $aray[$i]=$b; $aray[$j]=$a; } } }
Time of Update: 2016-07-28
變數分為全域變數和局部變數。學過C語言的童鞋都知道,全域變數的範圍是整個整個檔案。在即使在函數內部也有效,但在php中,如果在函數中使用全域變數,php會認為這個變數沒有定義。如果我們需要在函數內部使用這個全域變數,這時我們就需要在函數內部,這個全域變數前加關鍵字global。下面是自己寫的一個小demo。用來證明我上面說的$str = "string"; functiontest() {if (isset($str)) { echo"the
Time of Update: 2016-07-28
類內部使用 self::欄位 外部使用 類名::欄位classStaticTest{publicstatic$data =0; publicfunctionappend() {//類內部訪問靜態方法或屬性 使用self:://在其他語言中 一般是直接$data++;self::$data++; } } $p = new StaticTest(); $p->append(); $p2 = new StaticTest();
Time of Update: 2016-07-28
手冊上的解釋是:簡單的引用(換言之,“成為其別名” 或者 “指向”)了原始變數。改動新的變數將影響到原始變數,反之亦然。 我理解決引用相當一個人取了兩個名字,無論叫個名字都是這個人。 以下兩例子結果都在一樣的。刪除或修改都會影響到另外一個變數的值。$foo = 'Bob'; // 將 'Bob' 賦給 $foo$bar = &$foo; // 通過 $bar 引用 $foo$bar = "My name is $bar"; // 修改
Time of Update: 2016-07-28
wamp環境:Apache/2.4.9 (Win32) PHP/5.5.12 一、安裝Memcached伺服器端軟體 1.將memcached.exe檔案放於任意盤符下(此處放置F:\memecached); 2.開啟DOS視窗,執行如下指令: f: //進入F盤 cd memcached //進入memcached檔案 memcached
Time of Update: 2016-07-28
---------安裝先安裝依賴yum -y install openssl openssl-develyum -y install pcre-devel下載nginxwget http://nginx.org/download/nginx-1.10.0.tar.gz安裝先解壓tar -zxvf nginx-1.10.0.tar.gz再編譯cd nginx-1.10.0./configure --prefix=/usr/local/nginxmakemake
Time of Update: 2016-07-28
header("content-type:text/html;charset=utf-8");//解析中文編碼,必不可少class car{ // 定義car類 private $name; // 定義name屬性 function __construct($name){ // 建構函式 $this->name=$name; } public function getName(){ // 定義方法 return $this->name;
Time of Update: 2016-07-28
location:文法:location [=|~|~*|^~] /uri/如果使用Regex,你必須使用 ~* 首碼選擇不區分大小寫匹配或者 ~ 選擇區分大小寫匹配。使用Regex必須使用這個首碼如果使用的是一般字元串匹配則不需要使用 “=”首碼,將只執行嚴格匹配。如果這個查詢匹配,那麼將停止搜尋並立即處理這個請求。總結,指令按下列順序被接受:1. = 首碼的指令嚴格匹配這個查詢。如果找到,停止搜尋。2. 剩下的常規字串,長的在前。如果這個匹配使用 ^~
Time of Update: 2016-07-28
猴子吃桃 : 第一天吃一半 +1; 第二天吃一半+1; 10天后 剩一個 求一共有多少個$total=1; $totalar=array(); $totalar[0]=1; for($i=0;$i9;$i++){ $total=2*(1+$total); $totalar[$i+1]=$total; echo$total; }
Time of Update: 2016-07-28
functiontest() {static$nm = 1; $nm *= 2; print$nm."\n"; }// 第一次執行,$nm = 2 test(); // 第一次執行,$nm = 4 test(); // 第一次執行,$nm = 8 test();?>添加了static修飾符的變數即使在該函數執行完畢值仍然不會丟失,也就是說,在下一次調用這個函數時,變數仍然記得原來的值。
Time of Update: 2016-07-28
-鍵盤輸入四個學生的學號 姓名 語文 數學 英語資訊 ,計算出每個學生的平均成績,輸出 - 學生的資訊包括 學號 姓名語文 數學 英語 平均成績 ,4個學生的資訊存數組中。 $student=array();$student=array( array('name' =>'a' ,'chinese'=>80,'math'=>80,'english'=>70,'avg'=>'' ), array('name' =>'b'
Time of Update: 2016-07-28
文章轉載自 : http://blog.sina.com.cn/s/blog_4ce89f200100twbl.html首先set_include_path這個函數呢,是在指令碼裡動態地對PHP.ini中include_path進行修改的。而這個include_path呢,它可以針對下面的include和require的路徑範圍進行限定,或者說是預定義一下。 就好像: 如果我們沒有設定這個值,可能我們需要寫一些完全的路徑: include("1
Time of Update: 2016-07-28
安裝項目依賴接上一篇文章composer入門教程–編寫composer.json檔案(3)編寫的composer.json檔案,在composer.json檔案所在目錄命令列下執行如下命令: php composer.phar install或composer install安裝項目依賴成功後的檔案如下:
Time of Update: 2016-07-28
1.php利用mysqldump備份資料庫,代碼如下: '.$filepath;exec($sql); ?>2.通過bat運行以上php檔案,bat檔案內容如下:e:/wamp/php5.4.44/php.exe e:/wamp/backup.php zzy 30其中: e:/wamp/php5.4.44/php.exe :php安裝路徑; e:/wamp/backup.php :要啟動並執行php檔案; zzy :要備份的資料庫; 30 :備份資料儲存天數。
Time of Update: 2016-07-28
1.設定成輸入框,在列表中輸入並且修改給timelimit 設定一個onchange 事件 'columns'=>array( 'id', array('name' => 'platform', 'value' => '$data->platform'), array('name' => 'version',
Time of Update: 2016-07-28
瀏覽器執行個體化一個Ajax對象,這個對象發送一個HTTP請求,並且攜帶一定的參數,傳輸到後台。後台伺服器接收這些參數,同時過濾一下傳過來的參數,做出邏輯判斷。如果需要資料庫操作參與,就要取出資料,格式化資料。返回給前台用戶端,前台擷取的資料,對資料進行處理,擷取DOM元素,將資料放到局部。從而實現無數新技術。一般用到的地方主要是註冊模組郵箱和使用者驗證。
Time of Update: 2016-07-28
產生認證檔案產生自我簽署憑證,並放在指定位置$ openssl req -x509 -days 3650 -subj '/CN=odoo.youyun.com/' -nodes -newkey rsa:2048 -keyout server.key -out server.crt$ sudo mkdir /etc/ssl/nginx$ sudo mv server.key server.crt /etc/ssl/nginx配置nginx$ sudo rm
Time of Update: 2016-07-28
php 給指定檔案夾下的所有圖片批量打浮水印 以上就介紹了 php 給檔案夾下的所有圖片批量打浮水印,包括了方面的內容,希望對PHP教程有興趣的朋友有所協助。
Time of Update: 2016-07-28
mac啟動nginx報錯[emerg]bind() to 0.0.0.0:80failed (13: Permissiondenied)原因是1024以下連接埠啟動時需要root許可權,所以sudo ngin即可。').addClass('pre-numbering').hide(); $(this).addClass('has-numbering').parent().append($numbering); for (
Time of Update: 2016-07-28
在後台模板引入後,進行訪問,一般來說,在瀏覽器中