CakePHP2ではVer1.3とURL(GET)関係の取得方法が変わっています。
Ver2からは「$this->request->params」のように真ん中に「request」が入ります。
URLのパラメタが下記のような場合、それぞれ取得方法が変わります。
「http://www.example.com/posts/test/2」
「http://www.example.com/posts/test/?id=2」
URLが「http://www.example.com/posts/test/2」の場合
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
pr($this->request->params); //出力結果 Array ( [plugin] => [controller] => posts [action] => test [named] => Array ( ) [pass] => Array ( [0] => 2 ) ) |
URLが「http://www.example.com/posts/test/?id=2」の場合
1 2 3 4 5 6 7 8 |
pr($this->request->query); //出力結果 Array ( [url] => posts/test/ [id] => 2 ) |
人気記事一覧
- MySQL 最大の値・最新の日付データを1つ抽出する方法(MAX)
- [CakePHP] XformHelperの使い方
- Linux: スワップファイル(swp)の削除方法
- HTMLのForm methodとactionについて
- PHPでカンマ区切りデータを配列に入れる方法 (explode)
- [エラー対処] failed to open stream: No such file or directory
- [CSS]ブロック要素(div)の高さを、内部のfloat要素に合わせて自動調整する
- [vsftp] FileZillaから接続できない場合の対処法
- PHP5.1→PHP5.3へバージョンアップする方法(CentOS)
- PHPでテキストを1行ずつ読み込む方法(file_get_contents,explode)