| Routing คืออะไร ? | Routing มีไว้เพื่อกำหนด controller ที่จะถูก execute ในกรณีที่ไม่มีการกำหนด controller |
|---|---|
| วิธีการกำหนด Default Controller | วิธีการกำหนด Default Controller |
| $current_uri | ใช้คืนค่า uri ปัจจุบัน ( ตั้งแต่ controller จนถึง argument ตัวสุดท้าย ) |
| $query_string | ใช้คืนค่า query string |
| $complete_uri | ใช้คืนค่า Routing::$current_uri + Routing::$query_string |
| $routed_uri | ใช้คืนค่า default controller ที่กำหนดไว้ใน ตัวแปร $config["_default"] |
| $url_suffix | ใช้คืนค่า suffix ของ url เช่น php |
| $segments | ใช้คืนค่า segments ทั้งหมดแบบ array |
| $rsegments | ใช้คืนค่า segments ทั้งหมดแบบ array |
| $controller | ใช้คืนค่า controller |
| $controller_path | ใช้คืนค่า absolute path ของ url ปัจจุบัน คือตั้งแต่ drive ที่วางไฟล์นั้นๆ |
| $method | ใช้คืนค่า method ของ controller |
| $arguments | ใช้คืนค่า arguments ทั้งหมดแบบ array |
subject:Routing คืออะไร ?
content:Routing มีไว้เพื่อกำหนด controller ที่จะถูก execute ในกรณีที่ไม่มีการกำหนด controller ที่จะ execute
subject:วิธีการกำหนด Default Controller
content:ให้ copy file จาก "system/config" มาไว้ที่ "application/config" แล้วกำหนด ตัวแปร $config[ "_default" ] = "controller_name"; ( สามารถกำหนดไว้ใน file ที่อยู่ใน "system/config" เลยก็ได้ แต่แนะนำให้ไม่ควรไปแก้ไขอะไรใน "system" )
property:$current_uri;
return type:string
special:static
content:ใช้คืนค่า uri ปัจจุบัน ( ตั้งแต่ controller จนถึง argument ตัวสุดท้าย )
example:echo Routing::$current_uri;
property:$query_string;
return type:string
special:static
content:ใช้คืนค่า query string
example:echo Routing::$query_string;
property:$complete_uri;
return type:string
special:static
content:ใช้คืนค่า Routing::$current_uri + Routing::$query_string
example:echo Routing::$complete_uri;
property:$routed_uri;
return type:string
special:static
content:ใช้คืนค่า default controller ที่กำหนดไว้ใน ตัวแปร $config["_default"]
example:echo Routing::$routed_uri;
property:$url_suffix;
return type:string
special:static
content:ใช้คืนค่า suffix ของ url เช่น php
example:echo Routing::$url_suffix;
property:$segments;
return type:array
special:static
content:ใช้คืนค่า segments ทั้งหมดแบบ array
example:print_r ( Routing::$segments );
property:$rsegments;
return type:array
special:static
content:ใช้คืนค่า segments ทั้งหมดแบบ array
example:print_r ( Routing::$rsegments );
property:$controller;
return type:string
special:static
content:ใช้คืนค่า controller
example:echo Routing::$controller;
property:$controller_path;
return type:string
special:static
content:ใช้คืนค่า absolute path ของ url ปัจจุบัน คือตั้งแต่ drive ที่วางไฟล์นั้นๆ
example:echo Routing::$controller_path;
property:$method;
return type:string
special:static
content:ใช้คืนค่า method ของ controller
example:echo Routing::$method;
property:$arguments;
return type:array
special:static
content:ใช้คืนค่า arguments ทั้งหมดแบบ array
example:print_r ( Routing::$arguments );