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

Konrad Pilch
Konrad Pilch
2,435 Points

WHen do we exactly use :: ?

Hi,

When exactly do we use

::

So for example

static::$db_table

//and

User::find_all();

When exactly we need to use the :: ? and not for example $this-> or other sutff?

1 Answer

Nathaniel Kolenberg
Nathaniel Kolenberg
12,836 Points

Hi Konrad,

I asked the question as well to a developer at some point and they explained to me that sometimes you have functions defined as private in your Parent class, that you don't want to pass on to the instantiated Child objects. In that case, if you still want to use the private function, you would use Parent::function().

But in all honesty, I've not yet used this kind of method myself apart from using PDO functions such as PDO::PARAM_STR.

Kindly,

N8