MyBB Community Forums

Full Version: Can u give me some info?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I was searching in google but couldnt find info about the variable
$this->
that is used in classes so could u give me a link to some info?

Thanks
My tutor tought me that $this means "the current object in memory". That means that $this references to the current class so that $this->func1() will call the function func1() inside itself (the current class).

That was proberly not explained very well, so I will find you some documentation for it. Smile
In PHP, if $this is used inside a class, it refers to the current instance of the class.
I see, its just that i want to write something and i need to use $this but no info on internet
I am not sure if that means you understood or not, but either way, I'll break it down some more...

So we have a class:

<?php
class Awesome{

function test(){
//Do stuff
}

function anothertest(){
$this->test();
}

}
?>

So it just executes afunction inside the current class, so in that example, if the anothertest() function was called, it would call the test() function in that class.
dikidera Wrote:I was searching in google but couldnt find info about the variable
$this->
that is used in classes so could u give me a link to some info?

Thanks

Read the first paragraph
http://ca3.php.net/class