Like in url
Index.php/constructor/method/1
I want to get id. I used
anchor("constructor/method/{$article->id}",'Edit');
This does not work, I get the following error :
Using non-object as object
How can I retrieve the id value ?
If your 'id' is in the URI : index.php/constructor/method/1
You can get the value by using the URI library and segments.
ie.
uri : index.php/constructor/method/1
$id = $this->uri->segment(3);
Feel free to check other functions for URI segment manipulation on this page in docs.
I am not sure where you get $article->id
from because you have not pasted enough code.
Try on controller
$data['example'] = anchor("controller/method/" . $article->id,'Edit');
$this->load->view('example_view', $data);
Then on view
<?php echo $example_link;?>
You may need to set route
config/routes.php https://www.codeigniter.com/user_guide/general/routing.html#examples
$route['controller/method/(:any)'] = 'controller/method/$1';
config/autoload.php
$autoload['helper'] = array('url');