6
9月
0
CodeIgniter2 #03 $_GETを使えるように

いくら何でも、$_GET とれないと困るだろうということで、ここと、ここを参考にさせてもらって修正する。
- application/config/config.php の 修正
$config['allow_get_array'] = TRUE; $config['enable_query_strings'] = TRUE; $config['controller_trigger'] = 'c'; $config['function_trigger'] = 'm'; $config['directory_trigger'] = 'd'; $config['permitted_uri_chars'] = ''; $config['uri_protocol'] = "AUTO";
- application/config/hooks.php の修正
$config['enable_hooks'] = TRUE;
$hook['pre_system'][] = array(
'class' => 'ConvertQueryString',
'function' => 'execute',
'filename' => 'ConvertQueryString.php',
'filepath' => 'hooks',
'params' => array()
);
これで、$_GET のパラメータはすべて $_PUT にぶち込まれるので、バリデーションも行える様になる。ただ、getで呼び出すときには &c=controller&m=function を付加する必要がある。
※サーバによっては?以降がうまくとれないことがあるらしい。
※form_open (‘c=controller&m=func”) って書く必要がある
Enjoyed reading this post?
Subscribe to the RSS feed and have all new posts delivered straight to you.
Subscribe to the RSS feed and have all new posts delivered straight to you.
Post your comment