Vortico
Vortico

Reputation: 2749

What is going on with my PHP class variable?

I made this stupidly simple PHP file containing

<?php

class stuff {
    private $var;
}

?>

and results in this error when run:

Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in . . . on line 4

To make things even more confusing, it functions normally on a different domain with the same host. Surely the folder and domain have nothing to do with whether class properties can be defined. What is going on here??

Upvotes: 1

Views: 96

Answers (4)

paullb
paullb

Reputation: 4325

It looks like php4.

put

<?php phpinfo();> 

into a file and view it from a web browser. That will let you determine the version.

Upvotes: 1

Falmarri
Falmarri

Reputation: 48569

You mean a different domain hosted on the same server? It could be an error with your php installation.

Upvotes: 0

deceze
deceze

Reputation: 522024

Seems like PHP 4 is active on that particular domain/folder of yours.

Upvotes: 2

Artefacto
Artefacto

Reputation: 97815

That's legal PHP code. I'd guess you're testing it in a machine that has PHP 4 installed. Support for PHP 4 has been discontinued for a long time; it's strongly recommended to upgrade.

Upvotes: 6

Related Questions