This forum is now read-only. Please use our new forums at

463 points
Submitted by
James Barclay
over 5 years ago

Confusing error with PHP objects - Unexpected T_VARIABLE, expecting T_FUNCTION

Whenever I create a new instance of an object I receive this error:

Parse error: syntax error, unexpected TVARIABLE, expecting TFUNCTION on line ...(in the example to come, line 10)

The code passes each task, however I just wanted to know whether this is actually a legitimate error in how I'm writing the code or whether it is a error not related to me. Below is the simplest code I have done that still produces the error.

    <title>OOP Review</title>
    class Person{
          $me = new Person();

1 vote


You're supposed to create the instance outside of the class:

class Person{


$me = new Person();

322 points
Submitted by
over 5 years ago