The short: The code sample below does not echo "Here I am!" It will not echo from the _construct function. It will echo if I move the echo statement above the class so I know CI is reaching this controller.
The backstory:
I've inherited a project done in CodeIgniter 2.1.2. I'm supposed to replicate an application to another directory with a different subdomain and pointing the database config to a different database. I have the database updated in the config. I've updated the base bath. I've set environment to development so I can get error messages. There are no errors.
if (!defined('BASEPATH'))
exit('No direct script access allowed');
if (!ini_get('date.timezone')) {
date_default_timezone_set('my-time-zone');
}
class Login extends CI_Controller {
public function __construct() {
parent::__construct();
$this->load->model('mod_login');
$this->load->helper('date');
}
function index() {
echo "Here I am!"; //Nothing echos
}
function logout{
//logout function here.
}
}
Any CodeIgniter fans here have an idea why?
Your controller should be like this.
<?php
if (!defined('BASEPATH'))
exit('No direct script access allowed');
class Login extends CI_Controller
{
function __construct()
{
parent::__construct();
$this->load->model('mod_login');
$this->load->helper('date');
}
public function index()
{
echo "Here I am!";
}
}
and controller name should be loging.php
and in config/routes.php
$route['default_controller'] = "login";/set default conntoller
index.php in URL)in config/config.php
$config['base_url'] = '';
$config['index_page'] = '';
and .htaccess (place outside application folder)
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With