發表文章

目前顯示的是有「PHP」標籤的文章

在Linux上如何去找到php.ini目前配置預設路徑

  可用 php --ini  | grep 'Loaded Configuration File'

CI3.0开始支持translate_uri_dashes

  http://blog.smallerpig.com/665.html

Codeigniter redirect doubles URL

  https://stackoverflow.com/questions/22316745/codeigniter-redirect-doubles-url https://www.technhit.in/category/codeigniter/ http://webnas.bhes.ntpc.edu.tw/wordpress/archives/7933

Codeigniter3_程式進入點_控制器與View_Day02

圖片
  Codeigniter專案中預設程式進入點 也就是默認路由主要是在 ~/application/config/config.php 當中的 $config['base_url'] 主要是用於設定預設跳轉至哪個網站根URL ~/application/config/routes.php 當中則是可去指定$route['default_controller'] 預設要指向至哪個控制器 默認官網載下來範例給的是welcome 在welcome控制器中 所在程式路徑 ~/application/controllers/Welcome.php 裡面實作的是一個function 名稱index() 在進行load->view() 指定一個前端UI檢視名稱為welcome_message 的檔案 所在位置 ~\application\views\welcome_message.php Ref: https://www.wdb24.com/how-to-install-codeigniter-xampp/ https://www.learncode01.com/codeignitor-example/ https://sites.google.com/site/ageechen/work_notes/web-developing-in-php/codeigniter-mvc?authuser=0

Codeigniter3專案目錄結構_Day01

圖片
  Application Directory 應用程序文件夾將包含我們將要開發的所有應用代碼。應用程序文件夾包括如下 不同的文件夾 Cache:此文件夾包含應用程序的所有緩存頁面。 Config :此文件夾包含應用程序的一些關鍵PHP文件,如 autoload.php、config.php、 database.php、路由等。 Controllers:此文件夾包含應用程序的所有控制器。 Core:默認情況下,此文件夾只有 index.html 文件。但是你可以在這個文件夾中編寫自己的基類或者擴展核心類。 Helpers:此文件夾包含您要包含在應用程序中的所有輔助函數。 Hooks:通過使用掛鉤,您可以修改 codeigniter 框架內部工作文件,而無需更改 codeigniter 應用程序的核心文件。 Language:此目錄包含語言文件。 Libraries:它可能包含第三方庫或用戶定義的應用程序庫。 Logs:此文件夾包含日誌文件。 Models:這個文件夾有數據庫訪問文件。 Third_party:此文件夾可能包含將在應用程序中使用的任何第三方插件。 Views:此文件夾包含所有 html 頁面。 System Directory Core:這是包含整個核心類的主文件夾。請不要嘗試更改此文件夾中的任何文件。如果你想擴展任何核心功能,那麼你可以使用鉤子(應用程序/鉤子)。 Database:此文件夾包含數據庫文件,如緩存、驅動程序、查詢生成器等。 Fonts:這個文件夾有字體相關的文件。 Helpers:helper 文件夾包含通用的 codeigniter 幫助程序,如 url 幫助程序、數組幫助程序、日期幫助程序、cookie 幫助程序等。 Libraries:此文件夾包含 codeigniter 庫。您可以在 application/libraries 文件夾中創建自己的庫,也可以擴展或替換標準庫。 Language:此文件夾包含語言文件。 Ref: https://www.wdb24.com/codeigniter-framework-directory-structure/

[PHP_Day 9]_高階語法_取得HTML中的參數GET_POST

圖片
表單傳送值方式基本的有兩種(跟ASP一樣) GET (串後頭URL) formTest.html 1 2 3 4 5 6 7 8 9 10 11 12 13 <html> <head> <meta charset="UTF-8" > </head> <body> <form action="getPhone.php" method="get" > <div> 電話 </div> <input type="text" name ="phone" > <input type="submit" value="發送" > </form> </body> </html> getPhone.php 1 2 3 <?php echo "電話號碼:" . $_GET [ "phone" ]; ?> POST (表單傳送) formTest.html 1 2 3 4 5 6 7 8 9 10 11 12 13 <html> <head> <meta charset="UTF-8" > </head> <body> <form action="getPhone.php" method="post" > <div> 電話 </div> <input type="text" name ="phone" > <input type="submit" val...

[PHP_Day 8]_基本語法function

圖片
PHP函數的使用 在參數名稱上不能重複 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 <?php #無傳入參數的function(無回傳值) function printWebSiteTitle (){ echo "This is Title<br/>" ; } printWebSiteTitle(); #有傳入參數的function(無回傳值) function printSayHello ( $name ){ echo "Hello " . $name . "<br/>" ; } printSayHello( "Jack" ); #無傳入參數的function(有回傳值) function getPI (){ return 3.1415 ; } echo getPI(). "<br/>" ; #有傳入參數的function(有回傳值) function getMinusResult ( $num1 , $num2 ){ return ( $num1 - $num2 ); } echo getMinusResult( 8 , 2 ). "<br/>" ; ?> 函數中optional參數(有預設值,可省略的) optional 參數通常放於最後 這裡大括弧是用來相應輸出變數(前面要有$不然會變一般文字輸出)用的 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 <?php function Notify ( $title , $msg , $level = "Error" ){ if ( $level == "Error" ){ echo "<h1 style='color:red;...

[PHP_Day 7]_基本語法break 和 continue

圖片
Break 跟 Continue操作 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 <?php echo "continue使用<br/>" ; for ( $idx = 0 ; $idx < 10 ; $idx ++){ if ( $idx == 3 ) continue ; echo $idx ; } echo "<br/>" ; $idxVal = 0 ; while ( $idxVal < 10 ){ $idxVal ++; if ( $idxVal == 5 ) continue ; echo $idxVal ; } echo "<br/>break使用<br/>" ; $idxVal1 = 1 ; while ( $idxVal1 ){ echo $idxVal1 ; $idxVal1 ++; if ( $idxVal1 > 10 ) break ; } ?>

[PHP_Day 6]_基本語法part6_迴圈for_foreach

圖片
for loop 跟 foreach寫法 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 <?php $arr = [ "張三" , "李四" , "王五" ]; #$count = count($arr); #echo $count."<br/>"; echo "=======while loop======<br/>" ; $idx = 0 ; while ( $idx < count ( $arr )){ echo "名字:[" . $idx . "]" . $arr [ $idx ]. "<br/>" ; $idx ++; } echo "=======for loop======<br/>" ; for ( $idx2 = 0 ; $idx2 < count ( $arr ) ; $idx2 ++){ echo "名字:[" . $idx2 . "]" . $arr [ $idx2 ]. "<br/>" ; } echo "=======for v.s. foreach ======<br/>" ; echo "=======for======<br/>" ; $Students = [ [ "name" => "小明" , "數學成績" => 80 ], [ "name" => "小菲...

[PHP_Day 5]_基本語法part5_迴圈while_do..while

圖片
PHP迴圈 while 1 2 3 4 5 6 7 8 9 10 <?php $count = 5 ; while ( $count != 0 ){ echo "<h1>My Test</h1>" ; echo "Count: " . $count . "<br/>" ; $count --; } ?> Array遍歷(倒序) 1 2 3 4 5 6 7 8 9 10 <?php $arr = [ "blue" , "green" , "yello" , "white" ]; $count = count ( $arr ); echo $count . "<br/>" ; while ( $count --){ echo $arr [ $count ]. "<br/>" ; } ?> Array遍歷(正序) 1 2 3 4 5 6 7 8 9 10 11 12 <?php $arr = [ "blue" , "green" , "yello" , "white" ]; $count = count ( $arr ); $idx = 0 ; echo $count . "<br/>" ; while ( $count --){ echo $arr [ $idx ]. "<br/>" ; $idx ++; } ?> do ... while do裡面會先做 while裡面要改成先減減不然會offset 1 2 3...

[PHP_Day 4]_基本語法part4_Array、HashTable

圖片
陣列(可以不只侷限一種型態,可以是Object) 陣列的初始化有兩種寫一種是透過array小括號 一種則是直接一組方括號 可以用print_r來輸出整個array索引對應成員 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 <?php $arrStr = array ( "apple" , "banana" , "cherry" , "桃子" , "葡萄柚" ); var_dump ( $arrStr ); //陣列中string各自大小(Byte),一個中文字佔3Byte。 echo "<br/>" ; print_r ( $arrStr ); echo "<br/>" ; echo $arrStr [ 3 ]; echo "<br/>" ; $arrStr2 = [ "a1" , "a2" , "a3" ]; var_dump ( $arrStr2 ); echo "<br/>" ; print_r ( $arrStr2 ); echo "<br/>" ; echo $arrStr2 [ 1 ]; echo "<br/>" ; $arrInt = [ 15 , 68 , 77 , 98 ]; var_dump ( $arrInt ); echo "<br/>" ; print_r ( $arrInt ); echo "<br/>" ; $arrFloat = [ 9.8 , 5.4 , 3.1 , 6.24 ]; var_dump...

[PHP_Day 3]_基本語法part3_單行條件判斷(三元運算子)_switch case

圖片
單行條件判斷(三元運算子)_switch case 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 <?php $res = true ; // Before if ( $res ) echo "真<br/>" ; else echo "假<br/>" ; // After $str = ( $res == true ) ? "真<br/>" : "假<br/>" ; echo $str ; $result = 8 ; // Before if ( $result == 1 ) echo "1<br/>" ; else if ( $result == 2 ) echo "2<br/>" ; else if ( $result == 3 ) echo "3<br/>" ; else echo "else<br/>" ; // After switch ( $result ){ case 1 : echo "case.1<br/>" ; echo "1<br/>" ; break ; case 2 : echo "case.2<br/>" ; break ; case 3 : echo "case.3<br/>" ; break ; d...

[PHP_Day 2]_基本語法part2_字串、數字型態、布林_算數運算_比較運算_邏輯運算

圖片
字串、數字型態、數值相關內建函數操作 型態打印函數:var_dump (常用!!!) 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 <?php //整數int echo "整數int<br/>" ; $intVal = 10 ; var_dump ( $intVal ); echo "<br/>" ; echo $intVal ; //背後有進行轉型為string,因為echo只接受string。 echo "<br/>" ; echo "負整數int<br/>" ; $intVal2 = - 88 ; var_dump ( $intVal2 ); echo "<br/>" ; echo $intVal2 ; echo "<br/>" ; //16進制表示 echo "整數16進制表示<br/>" ; $intHexVal = 0xff ; var_dump ( $intHexVal ); echo "<br/>" ; echo $intHexVal ; echo "<br/>" ; //float echo "浮點數float<br/>" ; $floatVal = 9.567 ; var_dump ( $floatVal ); echo "<br/>" ; echo $f...