By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,747 Members | 2,039 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,747 IT Pros & Developers. It's quick & easy.

Variables in classes

P: n/a
How can I pass a variable out of a class?

I'm sure this is very simple, but I can't find out how. I think you put a
charater in front of the variable name, is this right?

Thanks for any help
Moe
Jul 16 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a


"moeFinley" <mo******@blueyonder.co.uk> wrote in message
news:Xn**********************************@194.117. 133.134...
How can I pass a variable out of a class?

I'm sure this is very simple, but I can't find out how. I think you put a
charater in front of the variable name, is this right?

Thanks for any help
Moe

I'm new to php oop also..but I can think of 2 ways to do this.

A: member vars in php are considered public as far as I know, so you should
be able to access them directly..i.e.
$blah = class::blah;
or
$blah = $class_Instance -> blah;

B: Include a getter method in your class description
$blah = $Instance -> getBlah();

someone please correct me if I'm wrong

cmosser
Jul 16 '05 #2

P: n/a
Chris Mosser wrote:
A: member vars in php are considered public as far as I know, so you
should be able to access them directly..i.e.
$blah = class::blah;
This only works for class methods in php (certainly in v4) or
$blah = $class_Instance -> blah;
This is the solution I posted for him in another group - he's asked this
question in multiposts everywhere!

B: Include a getter method in your class description
$blah = $Instance -> getBlah();


Best way, yes, but I guess telling him this answer would then give rise
to "What is a getter/setter method"!...

Matt
Jul 16 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.