Reputation: 53
I am using just installed CI 2.1.3 Following phpacademy tutorial I wrote in the routes.php:
$route['default_controller'] = "site";
(instead of: $route['default_controller'] = "welcome";)
and in controllers/site.php:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Site extends CI_Controller {
public function index() {
echo "default function started.<br/>";
}
public function hello(){
echo "hello function started.<br/>";
}
}
After uploading it to the server and going to the [www.mydomain.ext] it works ok (writes: "default function started.") BUT if I add 'this->hello();' to the index() function it throws a 500 error.
Why does it happen and how can I resolve this?
Thank you in advance.
Upvotes: 2
Views: 924
Reputation: 11830
Are you adding this->hello();
as you've mentioned above to your index function or $this->hello();
?
$this->hello();
should work fine (tested):
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Site extends CI_Controller {
public function index()
{
echo "default function started.<br/>";
$this->hello();
}
public function hello()
{
echo "hello function started.<br/>";
}
}
Upvotes: 2