Jump to content

Is there a way around using $this-> all the time


underthefake

Recommended Posts

I don't understand why I have to write $this-> every time to refer to a variable or function in an object in PHP.  I know in Java I don't need to always write this.variable, I can just refer to the variable directly.

Is there a way to refer to a variable belonging to the object without using $this-> all the time?  It is very annoying...

..and make your code completely unreadable? How are you then to know if you are accessing a local method variable or an object variable or a global variable. It's a simple pointer. Java has some very strong standards so I imagine you've had to deal with far worse. Dunno, maybe that why you came over to php ;)

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.