views:

296

answers:

5

Hi friends,

I have weird issue with CodeIgniter,

here is a start part of my controller

class Home extends Controller
{
    /** 
    * Constructor
    */ 
    public function __construct() {
     parent::Controller();

    }

...

everything is working fine at localhost, but when I try same at server, I come cross with an error like below:

Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /home3/blabla/public_html/blablabla/applications/frontend/controllers/home.php on line 22

I researched and people say it is about PHP4.. it should be PHP5. but my server has PHP5 on. what can be the reason?

appreciate helps! thanks a lot!

A: 

Are you having the same problem with the other functions in the class as well? because, as far as i know, you can't make a constructor public or private. It should be "function __construct()" only.

KeyStroke
You can make the __construct() function private.in php5 if you use "function functionName()" in a class it assumes the function is public.
Anthony
when i delete that __construct() , everything works fine. there is sth specifically wrong with this class! rest is fine. but i need to use __construct() , i have model loads, etc...
artmania
It's actually right there in the manual: `public function __construct() { }` http://php.net/manual/en/language.oop5.visibility.php
deceze
+2  A: 

It really sounds like the interpreter is stumbling on the public keyword which it doesn't expect, which is an indication of/problem with the site running on PHP4.

Make sure you're echoing the PHP version in the site itself, not just looking it up in some control panel.

Check if there are any .htaccess directives that may change the default handler to PHP4.

Sometimes the host may default to PHP4 for .php files and PHP5 only for .php5 files.

deceze
A: 

Take a look in your php.ini file for the php version that is running.

A: 

hi, I deleted public part and it works fine. it is weird! is that public really important in there!?

artmania
Access levels (public, private, protected) is another feature that was introduced in php5. So, as everyone else here as stated, your script must be running in php4. Put php_info() at the top of your script and you'll know for certain which interpreter is being invoked.
Mike B
+2  A: 

Hi everybody!

I'm so sorry! I dont know how come, but Bluehost info panel says PHP 5 is active. and i just believed that. when I make a php_info(); page just in case, i saw actually it is php 4 :/

I updated server for PHP5 and now everything is fine.

I'm sorry for messing. and thanks all you for great support!!!

artmania
flag as answered please
Nicky De Maeyer