• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Parsing Error

#1
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?
Reply

#2
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
Reply

#3
(01-04-2019, 03: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.
Reply

#4
And you Parent::__construct(); should be lower case parent::__construct();
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


Users browsing this thread:
1 Guest(s)


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.