Access property from include inside a class method in PHP
- by Jojo
How do you make a class property available to the other included file inside the same class' method?
// file A.php
class A
{
private $var = 1;
public function go()
{
include('another.php');
}
}
in another file:
// this is another.php file
// how can I access class A->var?
echo $var; // this can't be right
Is this possible given the scope. If var is an array then we can use extract but if var is not, we can wrap it in an array. Is there a better way?
Thanks!