I have the following code in helloworld.php:
<?php
class Helloworld extends CI_Controller {
public function __construct()
{
parent::__construct();
}
public function index()
{
$this->load->model("helloworld_model");
$data["result"] = $this->Helloworld_model->getData();
$data["page_title"] = "CI Helloworld appis";
$this->load->view("helloworld_view", $data);
}
}
?>
The code stops executing after calling the parent constructor, without giving absolutely any error messages. Nothing appears in /var/log/apache2/error.log either. If I echo something before constructor call, it is echoed. If I type gibberish before the constructor call, a proper error message is printed. Why is this happening?
The site is running on Ubuntu server 12.04 with Code Igniter 2.1.4. and PHP 5.3.
Other files are helloworld_model.php:
<?php
class Helloworld_model extends CI_Model {
public function __construct()
{
parent::__construct();
$this->load->database();
}
public function getData()
{
$query = $this->db->get("data");
if ($query->num_rows() > 0)
{
return $query->row_array();
}
else
{
show_error("Database is empty");
}
}
}
?>
And helloworld_view.php:
<html>
<head>
<title><?php echo $page_title ?></title>
</head>
<body>
<?php foreach($result as $row): ?>
<h3><?php echo $row["title"]?></h3>
<p><?php echo $row["text"]?></p>
<br />
<?php endforeach ?>
</body>
</html>
As far as I understand, the Controller constructor is what gets called absolutely first, so I don't think the rest of the files matter at this stage(?).
parent::__construct(); echo 'Hello';? Also do you have error reporting enabled anddisplay_errorson?