Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When did $this start working?

Tags:

object

php

static

Ok, all jokes aside...

I just noticed that I was able to refer to a static class propery using $this::$name. I don't remember ever running across that before since I always used self::$name or $this->name in my classes.

In what version of PHP did $this start working with static class properties?

like image 952
Xeoncross Avatar asked Aug 29 '26 12:08

Xeoncross


1 Answers

From the PHP5 changelog, v5.3.0 ( http://php.net/ChangeLog-5.php#5.3.0 ):

Added support for dynamic access of static members using $foo::myFunc(). (Etienne Kneuss)

So I suppose it's a fairly recent occurrence. :)

(Oh, and this refers to calling methods statically...I wonder if it's the same for accessing properties.)

like image 123
Faisal Avatar answered Sep 01 '26 00:09

Faisal



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!