I get:
Undefined variable: password
Undefined variable: host
Undefined variable: user
I am just curious why I am getting such notices, although the variable has been defined in the private section of the class.
Can't I use private data member of the class in the member function (because that would defeat the whole concept of OOP)?
The php file is:
class data_base //helps handling permissins
{
private $host;
private $user;
private $password;
public function feed_data($hst, $usr, $pwd)
{
$host=$hst;
$user=$usr;
$password=$pwd;
}
public function get_data()
{
$info=array("host"=>" ", "user"=>" ", "password"=>" ");
$info['host']=$host;
$info['user']=$user;
$info['password']=$password;
return $info;
}
}
$user1=new data_base;
$user2=new data_base;
$user1->feed_data("localhost", "root", ""); //enter details for user 1 here
$user2->feed_data("", "", ""); //enter details for user 2 here
$perm_add=$user1->get_data();
$perm_view=$user2->get_data();