I was wondering if someone could tell me the correct way to link to another page from within a view.
Is there a function for this or is it just the usual about
Cheers,
This question is related to
php
codeigniter
anchor
you can also use this code
//test" class="btn btn-primary pull-right">
<a href="<?php echo site_url('controller/function'); ?>Compose</a>
<a href="<?php echo site_url('controller/function'); ?>Inbox</a>
<a href="<?php echo site_url('controller/function'); ?>Outbox</a>
<a href="<?php echo site_url('controller/function'); ?>logout</a>
<a href="<?php echo site_url('controller/function'); ?>logout</a>
you can also use PHP short tag to make it shorter. here's an example
<a href="<?= site_url('controller/function'); ?>Contacts</a>
or use the built in anchor function of CI.
Best and easiest way is to use anchor tag in CodeIgniter like eg.
<?php
$this->load->helper('url');
echo anchor('name_of_controller_file/function_name_if_any', 'Sign Out', array('class' => '', 'id' => ''));
?>
Refer https://www.codeigniter.com/user_guide/helpers/url_helper.html for details
This will surely work.
The best way is to use the following code:
<a href="<?php echo base_url() ?>directory_name/filename.php">Link</a>
Source: Stackoverflow.com