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 trialKonrad Pilch
2,435 PointsOOP PHP Basics with Hampton
Is the class Product related to the 'new Product'? is this the same ot the class can have different name then the product new?
1 Answer
Andrew Shook
31,709 PointsYes, the "new" keyword, in this context, tell's PHP to create a new Object based on the Product class. Think of a Class as a blueprint for a house, and an Object as a house that has been built from the blueprint. Also, classes can have any name you want to give them. Want a class called "Gizmo", you can have a class called Gizmo. The only caveat to naming classes is you can not have two classes in the same namespace with the same name. If you don't know what a name space is don't worry. Just try not to name two classes the same name.
Konrad Pilch
2,435 PointsKonrad Pilch
2,435 PointsHmm, did somebody called that PHP is messy before xd, having lots of this seem messy : p but well my point is :
So basically if i want to create a user on the registration for example ii would do it in this way :
I would create a class User and in that class i would make variables or something with e.g username, firstname, lastname, password,email, avatar etc.. right?
Then with the new User , now it a object where i can execute thing with this->username and this will basicaly take every user that registered and put it in the class and then the class will become a person on the object new User which means that now the user has the name, password etc.. ?
btw wow what a timing, i just went on treehouse and you wrote xD idnt log in for like 10hours