Welcome Guest, Not a member yet? Register   Sign In
__construct() { issue for PHP4 and PHP5. maybe an another reason…
#1

[eluser]artlover[/eluser]
Hi friends,

I have weird issue with CodeIgniter,

here is a start part of my controller
Code:
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:

Code:
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!
#2

[eluser]wiredesignz[/eluser]
So which is line 22 ?
#3

[eluser]artlover[/eluser]
LINE 22 : public function __construct() {


if there was a problem with code or syntax, it would not work at local as well. but it works well :/
#4

[eluser]wiredesignz[/eluser]
By all accounts this is a PHP4 error generated when it encounters PHP5 specific code.
#5

[eluser]artlover[/eluser]
[quote author="wiredesignz" date="1249493232"]By all accounts this is a PHP4 error generated when it encounters PHP5 specific code.[/quote]

yes this is what i read at forums, but my server is

PHP version 5.2.9
#6

[eluser]Nicholas Bello[/eluser]
Quote:yes this is what i read at forums, but my server is

PHP version 5.2.9

Did you get that (the php version) from your hosting company or did you find that out by running

Code:
<?php phpinfo(); ?>

You already said the code works fine on your local machine which has php5. I would run the above command on your hosting server and see what it says.

-Nick
#7

[eluser]Zorancho[/eluser]
Instead of __construct() use function Home();
This is what the PHP manual says:
"For backwards compatibility, if PHP 5 cannot find a __construct() function for a given class, it will search for the old-style constructor function, by the name of the class. Effectively, it means that the only case that would have compatibility issues is if the class had a method named __construct() which was used for different semantics. "




Theme © iAndrew 2016 - Forum software by © MyBB