Welcome Guest, Not a member yet? Register   Sign In
echo redirection
#1

[eluser]Captain_Fluffy_Pants[/eluser]
How to echo a redirection in a controller?
i tried
Code:
<?php
class Blog extends CI_Controller {

public function index()
{
  echo page_url'pages/home';
}

public function comments()
{
  echo 'Look at this!';
}
}
but that didnt work.
#2

[eluser]term25[/eluser]
page_url'pages/home'is wrong

you can use instead

Code:
base_url('pages/home');

or

Code:
site_url('pages/home');

btw. you need to use
Code:
die();
after the echo in your controller if you want to stop execution the code and check what is the problem when debugging like:

Code:
echo base_url('pages/home');
die();

The other way is to send the value to your view like:

Code:
$data_to_send_to_view = base_url('pages/home');
$this->load->view('your-view', $data_to_send_to_view);

And in your view output like:
Code:
echo $data_to_send_to_view;




Theme © iAndrew 2016 - Forum software by © MyBB