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


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.


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


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.


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


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


  • Parse error: syntax error in Wordpress [duplicate]
  • Changing php script to PDO causing Syntax error during MySQL update query
  • Exclude a field on a Elasticsearch query
  • Mongoose, MongoDB: How to save() document after push()?
  • Jekyll Posts Not found
  • Parse error: syntax error, unexpected (T_STRING), expecting variable (T_VARIABLE) [closed]
  • How can I insert javascript in php?
  • Parse error: syntax error, unexpected '' (T_ENCAPSED_AND_WHITESPACE) [duplicate]
  • GreaseMonkey: GM_xmlhttpRequest return value to calling function
  • Reset MySqli pointer?
  • Can't access index in folder when rewrite engine removes .php and .html
  • FPDF Fatal error: Allowed memory size of 33554432 bytes exhausted (PHP)
  • Swiftmailer email message returns error when attaching file
  • Wordpress header external php file - change title?
  • How can I update my Twitter status with Perl and only LWP::UserAgent?
  • Should I optimize around reads or CPU time in Google App Engine
  • proxy request in node.js / express
  • Error Processing Request: Mage registry key “_singleton/inchoo_notes/feed_updates” already exists
  • git cherry-pick: how consider only lines modified by the commit (i.e., not the surrounding context)?
  • How to override List.Add method?
  • Quick Question About Get and Set
  • EF 4.1 DBContext AutoDetectChangesEnabled
  • back button function for phonegap windows phone 7
  • Binary trees in scheme
  • Microsoft Excel Pivot miscalculation in Sum for positive and negative numbers
  • Can long-polling be achieved in Restlet by just making the thread sleep?
  • How to convert integer to string and get length of string
  • Retaining data after updating application
  • What causes the runtime difference in this trivial fortran code?
  • NHibernate manually control fetching
  • In-place sed command not working
  • CXF JAXB JAXBEncoderDecoder unmarshalling error : unexpected element when having qualified elements
  • Unexpected token ILLEGAL while running node.js mocha test
  • Eloquent paginate function in Slim 3 project using twig
  • How to suppress a dialog
  • Syntax for setting draggablecursor property in google maps api
  • Unit Testing MVC Web Application in Visual Studio and Problem with QTAgent
  • How to CLICK on IE download dialog box i.e.(Open, Save, Save As…)
  • Bitwise OR returns boolean when one of operands is nil
  • MATLAB: Piecewise function in curve fitting toolbox using fittype