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.
Gregg Squire14,829 Points
If you are using a static property, why would you create a shirt object and then "echo $shirt::$manufacturer;"?
Isn't the whole point of using a static property or method so that you don't need to create an object, so you can type "echo product::$manufacturer;"?
Andrew Shook31,709 Points
No, the point of a static property or method is to have a variable or function that is available to all objects of that class.
Tom Hudock855 Points
I agree with Gregg and Andrew. This part of the tutorial doesn't make sense. If the whole idea of using :: is so that you can access properties and methods in an object without having to instantiate them, then why create the $shirt object and then call $shirt::manufacturer? Wouldn't Product::manufacturer be the proper way to access a static property in a class that hasn't been instantiated?
Yep, the course examples are confusing. I understand the concepts but the examples don't really show why you would use the static keyword. It reminds me of situations when im in a conference room discussing issues with my fellow developers, then the next sentence they say "OK let me explain it another way" LOL. I still give props to the teacher. Its just hard sometimes explaining certain concepts.
This tutorial is bit confusing! This tutorial doesn't explain static property and method right way, examples in this tutorials are using objects to access static methods or properties but defination on http://us2.php.net/manual/en/language.oop5.inheritance.php says something like,
"Declaring class properties or methods as static makes them accessible without needing an instantiation of the class."