CodeIgniter Forums
Parsing Error - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24)
+--- Thread: Parsing Error (/showthread.php?tid=72543)



Parsing Error - Sovani Shreeniwas - 01-04-2019

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?


RE: Parsing Error - ciadmin - 01-04-2019

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?action=help&hid=7


RE: Parsing Error - Sovani Shreeniwas - 01-04-2019

(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?action=help&hid=7

Thanks. with above the error has gone. But now I am getting page not found message.


RE: Parsing Error - InsiteFX - 01-04-2019

And you Parent::__construct(); should be lower case parent::__construct();