Call Variable from a function to another function within PHP class
930
i use this class below i want use the variables array or property array ($g_types) in first_function how i can do this?
class My_Class {
function first_function() {
//HOW I CAN USE THE $g_types array Variable values in this function?
}
function second_function() {
$g_types = array(
'Person Widget' => 'g_person',
'Page Widget' => 'g_page',
'Community Widget' => 'g_community'
);
}
}
Answer
Solution:
One possible way to archive this, is by using a class-variable.
Answer
Solution:
Well you can return $g_types in second function and use it in first function.
But i suggest you to read about scope of the variables in php so that you won't encounter this problem anymore.