I created a file test.class.php containing the following code in a LAMP environment:
<?php
class MyClass
{
public var $variable;
};
$obj = new MyClass();
?>
When I run:
php myclass.php
from the command line, I get the error:
Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or ‘}’ in /path/html/_dev/classes/test.class.php on line 5
If I access the same file via the browser, I get no errors. Any suggestions on what might be happening?
Figured it out. The PHP CLI version that the PHP command defaults to in my environment is PHP 4.4.8.
My host also has a PHP5 command set up to use PHP 5.2.14. When I executed the command
Everything worked correctly. However, the code I posted originally produced another error. The
line, which was a solution to another Stack Overflow post didn’t work. I replaced it with
and was able to test succesfully with that change.
This link helped out a lot
http://www.yiiframework.com/forum/index.php?/topic/4319-error-on-yiibase-php-on-line-55/