Dear all,
I am confused about the output of the below programs .When i use the scope resolution operator i am getting the below error.
<?
class MyClass{
public $variable_value="This is a variable value ";
function display(){
echo "Display Function \n";
echo $this->variable_value;
}
}
MyClass::display();
//$obj=new MyClass();
//$obj->display();
?>
output:
Display Function
PHP Fatal error: Using $this when not in object context in /var/www/html/programs/class_scope.php on line 6
When i use the object i am not getting the error .The program works fine .What is the major difference between those two programs.
<?
class MyClass{
public $variable_value="This is a variable value ";
function display(){
echo "Display Function \n";
echo $this->variable_value;
}
}
//MyClass::display();
$obj=new MyClass();
$obj->display();
?>
Difference between scope resoultion operator and object?Can any one explain about this criteria?
Thank you,
With Regards,
Prem