LevelUp! Studio » url https://blog.levelup.in.th Experience the new world. Fri, 26 May 2017 10:06:07 +0000 th hourly 1 http://wordpress.org/?v=3.8.1 CI : ใช้ Query String กับ CodeIgniter https://blog.levelup.in.th/2009/05/12/ci-%e0%b9%83%e0%b8%8a%e0%b9%89-query-string-%e0%b8%81%e0%b8%b1%e0%b8%9a-codeigniter/ https://blog.levelup.in.th/2009/05/12/ci-%e0%b9%83%e0%b8%8a%e0%b9%89-query-string-%e0%b8%81%e0%b8%b1%e0%b8%9a-codeigniter/#comments Mon, 11 May 2009 19:59:37 +0000 http://blog.levelup.in.th/?p=12 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);

]]>
https://blog.levelup.in.th/2009/05/12/ci-%e0%b9%83%e0%b8%8a%e0%b9%89-query-string-%e0%b8%81%e0%b8%b1%e0%b8%9a-codeigniter/feed/ 0
PHP : Get Full URL path https://blog.levelup.in.th/2009/03/30/php-get-full-url-path/ https://blog.levelup.in.th/2009/03/30/php-get-full-url-path/#comments Sun, 29 Mar 2009 19:15:05 +0000 http://levelup.in.th/?p=6 Code สำหรับ Get URl ปัจจุบันในขณะนั้น


function full_url()
{
$s = empty($_SERVER["HTTPS"]) ? '' : ($_SERVER["HTTPS"] == "on") ? "s" : "";
$protocol = substr(strtolower($_SERVER["SERVER_PROTOCOL"]), 0, strpos(strtolower($_SERVER["SERVER_PROTOCOL"]), "/")) . $s;
$port = ($_SERVER["SERVER_PORT"] == "80") ? "" : (":".$_SERVER["SERVER_PORT"]);
return $protocol . "://" . $_SERVER['SERVER_NAME'] . $port . $_SERVER['REQUEST_URI'];
}

]]>
https://blog.levelup.in.th/2009/03/30/php-get-full-url-path/feed/ 0