テクノロジー遊び

CodeIgniterでの入力の受け取り方

GETリクエストはCodeIgniterでは、原則、使われません。

Inputクラス

Postデータを受け取るには、

$something = $this->input->post(‘something’);

Apache Rewriteを受け取る

ApacheでRewriteモジュールを使うと、

url/index.php/クラス/メソッド/第一パラメータ/第二パラメータ

と渡される。引数が少なく、かつ、短いときには、この手法が取られる。
例えば、
http://localhost/blog/edit/123/
というURIがあったら、
blogクラスのeditファンクションに123が第一パラメータに与えられる。

ちなみに、上記におけるindex.phpはapacheの.htaccessに次のように書くことで省略できる。

RewriteEngine on
RewriteCond $1 !^(index.php|css|user_guide|.+gif$|.+.jpg$|.+.png$|.+js$|robots.txt)
RewriteRule ^(.*)$ /cim/index.php/$1 [L]

関連記事

  1. PIC12F629のソフトウェアによるスイッチ

  2. CodeIgniterこそを使いたい

  3. PIC MPLAB Xのバージョンあげた

  4. PICでwaitのループを簡単に作る方法

  5. CodeIgniterでのユーザー認証2(MY_Controller)…

  6. PHPのクラスの継承

  7. スマホから機器をBluetoothでオン・オフ

  8. M5StickCを時計に