CI : ใช้ Query String กับ CodeIgniter by

12
May
0

Refer : http://www.askaboutphp.com/tutorials/58/codeigniter-mixing-segment-based-url-with-querystrings.html

Codeigniter ตามปกติจะไม่สามารถใช้งาน URL โดยมีตัวแปน GET (Query String) ได้

example.com/product/search/?pname=test&pid=2

หากต้องการให้ใช้งานได้มีสองวิธี

1. Global

ตั้งค่าใน Config.php ตามนี้

$config['uri_protocol'] = "PATH_INFO";
$config['enable_query_strings'] = TRUE;

2. Local

แบบ global จะมีปัญหาเล็กน้อยเรื่องตัวแปรชื่อ c , m , d ซึ่งเป็น default สำหรับเรียก controller เมื่อ $config['enable_query_strings'] = TRUE;

แบบ local จะตั้งค่าใน Config.php ตามนี้


$config['enable_query_strings'] = FALSE;
$config['uri_protocol'] = "PATH_INFO";

และใน Controller Initialize ให้แทรกบรรทัดนี้


parse_str($_SERVER['QUERY_STRING'],$_GET);

Enjoy this article?

Consider subscribing to our RSS feed!

ไม่มีความเห็น

ยังไม่มีความเห็น

ใส่ความเห็น

RSS feed for comments on this post

 เราชนะรอบ 4 | ยืมเงิน 3000 ด่วน | แอพกู้เงิน | แอพเงินด่วน | สินเชื่อออนไลน์อนุมัติทันที | Site Map | กู้เงินก้อน | กระเป๋าตัง | thisshop และ ยืมเงินฉุกเฉิน 5000 ด่วน