tags:

views:

73

answers:

4

I am getting the following error:

Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}'

The referenced lines are:

class Food {

private $q = array();   
private $nutrients = array();

...

How can I fix this error?

A: 

I think you're missing an ending curly brace '}'. (at least you did in the provided code).

But it's hard to tell with as less code as you provided. Please provide more code on the issue.

Michael Barth
A: 
class Food {

private $q = array();
private $nutrients = array();

}
SteD
A: 

This is likely to be caused by a string that is declared further on in your class somewhere outside any function calls or variable declarations.

Another likely cause is a missing semicolon on the end of one of your declarations.

Can you please provide more code (including the offending line number).

Josiah
+4  A: 

you can only use "private" in a php 5 environment. It looks like you're running that in PHP 4.

Lance Kidwell
I double-checked what version of PHP I was using, and it was PHP4! I switched it to PHP5 and it works now. Thanks!
Yongho