Question

I'm running CodeIgniter 2.1.3.

I've gone through posts such as but could not solve my problem:

Blank Screen with CodeIgniter

I've installed CodeIgniter under /var/www/ci/ and access it as http:// localhost/ci/

I've created the simple page application/controllers/helloworld.php

<?php
class HelloWorld extends Controller {
  function HelloWorld() {
  //function __construct() {
    //parent::__construct();
    parent::Controller();
  }
  function index() {
    echo "Hello, World!";
  }
}

but http:// localhost/ci/index.php/helloworld/

gives me a blank page. How can I fix this?

I've even tried changing config.php to contain

$config['base_url'] = 'http:// localhost/ci/';

(without the extra space in localhost ).

I've got mod_rewrite enabled, I've got mysqli php module enabled.

Where am I going wrong?

Thanks.

Was it helpful?

Solution

In the 2.x.x versions of CodeIgniter the these classes are called like CI_Controller (every other system class is prefixed with CI_.

Try changing it like this:

class HelloWorld extends CI_Controller {
   // if you don't want to do anything in the __controller you don't have to
   // override it, so its omitted

   public function index() {
       echo "Hello, World!";
   }
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top