CodeIgniter Forums

Full Version: Parsing Error
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I am getting below error.

Severity: Parsing Error
Message: syntax error, unexpected end of file, expecting function (T_FUNCTION)
Filename: controllers/Calsoft.php

My Controller file is as below:

<?php

class Calsoft extends CI_Controller{

    public function _construct()

    {

        Parent::_construct();

        $this->load->model('datas');

        

    }



    public function view($menu='menu')

    {

        $selection=$this->load->view('menu');

        

        switch ($selection) {

            case "General":

/*              $this->load->view(general); */

                echo "hello";

                break;

                

            case "customer list":

                $this->load->view('MasterDataEntry');

                break;

                

            default:

                echo "khatam";

                

            }
    }

What is the corrective action I can take?
There are two problems with your code:
1) You are missing a closing brace. Your second last line closes the switch construct, and your last line closes the view() function. Nothing closes the class definition. That is what your error message tells you.
2) Your constructor name is wrong. It should have two underscores, i.e. __construct() instead of _construct().

ps Please use bbcode in posts, so that large blocks of code don't make a super long page... https://forum.codeigniter.com/misc.php?a...help&hid=7
(01-04-2019, 02:30 AM)ciadmin Wrote: [ -> ]There are two problems with your code:
1) You are missing a closing brace. Your second last line closes the switch construct, and your last line closes the view() function. Nothing closes the class definition. That is what your error message tells you.
2) Your constructor name is wrong. It should have two underscores, i.e. __construct() instead of _construct().

ps Please use bbcode in posts, so that large blocks of code don't make a super long page... https://forum.codeigniter.com/misc.php?a...help&hid=7

Thanks. with above the error has gone. But now I am getting page not found message.
And you Parent::__construct(); should be lower case parent::__construct();