This is my class code:
class myClass
{
public function myFunc()
{
$myvar = \'Test str\';
}
public function result()
{
echo myClas
the problem is the scope, you can't call a variable within another function, define a property for the class and set it from a function then retrieve the property with result()
:
class myClass
{
public $myvar;
public function myFunc()
{
$this->myvar = 'Test str';
}
public function result()
{
echo $this->myvar;
}
}