开发者

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


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.


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


It looks like php4.

put

<?php phpinfo();> 

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


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜