PHP get methods
Posted: Wed Jan 28, 2009 3:13 pm
Hi,
I am pretty new at php so this may be a miss understanding on my part.
I have class A and Class B. Class A has a few private variables and a few get methods to return those values like:
class number {
private $m_number;
public function get_number() {
return $this->m_number;
}
}
In class B I have:
num = new number();
throw new Exception($num->get_number);
I am throwing an exception only to see what the number is to verify it.
The number is set in a third method but I know it is getting set to a number, thats not my problem.
My problem is that nothing shows up and I can't get the number that is stored in the private member variable.
I found that if I change the private to public then it seems to work. Anyone have a way to get the private
variable from the other class? I cant seem to get anything to return.
Thanks.
I am pretty new at php so this may be a miss understanding on my part.
I have class A and Class B. Class A has a few private variables and a few get methods to return those values like:
class number {
private $m_number;
public function get_number() {
return $this->m_number;
}
}
In class B I have:
num = new number();
throw new Exception($num->get_number);
I am throwing an exception only to see what the number is to verify it.
The number is set in a third method but I know it is getting set to a number, thats not my problem.
My problem is that nothing shows up and I can't get the number that is stored in the private member variable.
I found that if I change the private to public then it seems to work. Anyone have a way to get the private
variable from the other class? I cant seem to get anything to return.
Thanks.