model problem

Hey Guys,

I have a silly question, I have two models like this

public function user()

{

$name = "test";

}

public function call()

{

I want to call $name variable here. is that possible? I really appreciate if anyone can help me how to solve this nobis question…

}

I see you have two methods there. you have defined $name as a local variable in your user method so it will not be available to the call method.

You could do:




class myModal {

protected $name;




public function user() {

   $this->name = "my name";

}


public function call() {

   return $this->name;

}

}



Still have problem. Here is my code

protected $A;

protected $B;

public $name = "abc";

public function ret()

{

$A = ‘this is test’;

$B = ‘this is test1’;

}

public function retrieve()

{

$this->C = $this->A .$name. $this->B;

}

Hi,

i don’t know if i understood your problem but it should be:




protected $A;

protected $B;


public $name = "abc";

public function ret()

{

 $this->A = 'this is test';

 $this->B = 'this is test1';


}

public function retrieve()

{

 $this->C = $this->A .$this->name. $this->B; //btw. there is no $C?!

}



Regards