Good morning everybody, I have a two class, the first accesses the second class.
More on segunta class has a private $ my, and this gives the error Undefined pro开发者_Python百科perty: session::$my
in line, if($this->my)
I would be very grateful for the help.
Sample code,
class session{
public function run_session(){
..run..
data::run($line);
}
}
class data {
private $my = "../../my/";
public function run($line){
if($this->my.$line){
....run...
}
}
}
you must use like this
class data {
private $my = "../../my/";
public function run($line){
if($this->my.$line){ // here you are using $this, so the function must be called on object of class data
....run...
}
}
}
class session{
public function run_session(){
..run..
$data = new data(); // create object of class data, so that you can call the function run
$data->run($line);
}
}
精彩评论