How to make button redirecting to external link in codeigniter?

Member

by adan , in category: PHP Frameworks , 8 months ago

How to make button redirecting to external link in codeigniter?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

Member

by shyann , 8 months ago

@adan 

In CodeIgniter, you can create a button that redirects to an external link using the anchor() function provided by CodeIgniter's Url Helper.


Here's an example code snippet to create a button that redirects to an external link in CodeIgniter:

  1. Load the Url Helper in your controller or view:


$this->load->helper('url');

  1. Create a button with the anchor() function in your view file:


echo anchor('https://www.example.com', 'Go to External Link', array('class' => 'btn btn-primary'));


This will create a button with the text "Go to External Link" that redirects to the external link "https://www.example.com" when clicked. You can also add classes or any other HTML attributes to style the button as needed.


Remember to replace "https://www.example.com" with the actual external link that you want the button to redirect to.


That's it! You have now created a button that redirects to an external link in CodeIgniter.