Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

PHP Object-Oriented PHP Basics (Retired) Classes and Objects Object Oriented Concepts

Darryl Amatsetam
Darryl Amatsetam
6,141 Points

Why is my answer incorrect

I come from Java. When I'm answering a question related to this quiz regarding the definition of variables in an object, the answer 'field' is considered incorrect. Why is that?

Hayden Taylor
Hayden Taylor
5,076 Points

Because its treehouse.

Field is also a correct answer. They should word the question better.

1 Answer

Kazimierz Matan
Kazimierz Matan
13,257 Points

Property and field is not exactly the same.

Although Wikipedia is not always a reliable source of information, but in this case it can be useful: "A property, in some object-oriented programming languages, is a special sort of class member, intermediate between a field (or data member) and a method. Properties are read and written like fields, but property reads and writes are (usually) translated to get and set method calls."

PHP official documentation also prefers properties: Class member variables are called "properties". You may also see them referred to using other terms such as "attributes" or "fields", but for the purposes of this reference we will use "properties".