designer-trying-coding
designer-trying-coding

Reputation: 6074

__construct() { issue for PHP4 and PHP5. maybe an another reason

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!

Upvotes: 0

Views: 1170

Answers (5)

designer-trying-coding
designer-trying-coding

Reputation: 6074

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!!!

Upvotes: 2

designer-trying-coding
designer-trying-coding

Reputation: 6074

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

Upvotes: 0

user140125
user140125

Reputation: 143

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

Upvotes: 0

deceze
deceze

Reputation: 522372

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.

Upvotes: 4

KeyStroke
KeyStroke

Reputation: 1485

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.

Upvotes: 0

Related Questions