PHPMine
<? if(PHP > $Expectations) echo $Results ?>
by Angel S. Moreno
UNDER SOME SERIOUS CONSTRUCTION LINKS MAY NOT WORK
Asked 2010-03-07 10:50:39 by Smith
For example
<?php
class my_class
{
var $my_var;
function my_class ($var)
{
global $obj_instance;
$obj_instance = $this;
$this->my_var = $var;
}
}
$obj = new my_class ("something");
echo $obj->my_var;
echo $obj_instance->my_var;
?>
What is $this doing?
Anwered 2010-03-07 10:57:31 by jimbot
$this refers to the instance of the object in which it is currently operating.
In the case of your example, $this refers to the object contained in the global variable $obj.
Questions and answers provided by the Yahoo Answers Community.