Can I Call Function In Controller From View Page?

Controller have showdetails() function I want to call this function from index.php page.

Can I? and How?

Not quite clear what you’re trying to do.

Do you want it to be displayed on, for example, button click? then you can use ajax.

<?php echo $this->function_name(); ?>

In my opinion, it’s better for you to put the function in components (if it’s specific to your current application) or extensions (if it’s generic function that can be reused for other application).