Hi All,
I am trying to create the instance of a class without using new.
class StaticVar
{
public $i;
function __construct()
{
$i=8;
}
public function StaticVar()
{}
public function display()
{
echo $i;
echo $count;
}
}
$instance = new StaticVar();
StaticVar $instance2;
$instance->display();
$instance2.display();
It is giving no error for $inatance , but is giving error for $instance2
Can anyone please explain why we cannot create an instance without new as we do in C++?