Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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".