Index.php/constructor/method/1
のように、私はIDを取得したいです。 私はこれが動作しない
anchor("constructor/method/{$article->id}",'Edit');
を使用し、私は次のエラーを取得する:オブジェクト
などの非オブジェクトを使用して
は、どのように私はid値を取得することができますか?
Index.php/constructor/method/1
のように、私はIDを取得したいです。 私はこれが動作しない
anchor("constructor/method/{$article->id}",'Edit');
を使用し、私は次のエラーを取得する:オブジェクト
などの非オブジェクトを使用して
は、どのように私はid値を取得することができますか?
あなたの「ID」は、URIである場合は、次のindex.php /コンストラクタ/メソッド/ 1
あなたは、URIライブラリとセグメントを使用して値を取得することができます。
ie。
URI:のindex.php /コンストラクタ/方法/ 1
$ ID =の$ this - > uri->セグメント(3)。
this pageのURIセグメント操作の他の機能をドキュメントで確認できます。
十分なコードを貼り付けていないため、$article->id
がどこから届くのか分かりません。
は次にビュー
<?php echo $example_link;?>
にあなたがルート
のconfig/routes.phpのhttps://www.codeigniter.com/user_guide/general/routing.html#examples
$route['controller/method/(:any)'] = 'controller/method/$1';
のconfを設定する必要があり、コントローラ
$data['example'] = anchor("controller/method/" . $article->id,'Edit');
$this->load->view('example_view', $data);
にしてみてくださいig/autoload.php
$autoload['helper'] = array('url');
生成されたアンカーはどのように見えますか? – ourmandave
もう少し詳しく質問に含めるようにしてください。 –