2
I have two functions in one class, how to do to take the value of a variable that is within a function and take advantage of that same variable in another function of the same class. I want to make the variable $userFullname Global to be used in every class.
public function GetHtml($data)
{
$this->data = $data;
$quizinfo = $this->data['quizinfo'];
$quizinfo = (object) $quizinfo;
foreach ($this->data['users'] as $key => $user) {
$userFullname = $user['firstname'] . $user['lastname'];
}
Make this variable (local) a class member
– rray
You have two functions in class or has two methods. Need to be clearer. If possible, enter the code for us to analyze
– Wallace Maxters
Humberto, just to understand the difference:
funções
are reusable code snippets, are declared class independent.métodos
are the "functions" you define in a class. Just to understand the names– Wallace Maxters