Accessing Varible inside a class

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Steve007
Forum Newbie
Posts: 1
Joined: Thu Aug 14, 2008 6:12 am

Accessing Varible inside a class

Post by Steve007 »

Class XX extends blah
{
protected $yyy = array('test', 'test1', 'test2');
}

Ok, so here is the hard part.

I have $classname (currently set to XX)

So:

$classname = 'XX';

How can I get the value of XX's $yyy without creating an object?
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Re: Accessing Varible inside a class

Post by pickle »

Code: Select all

$importedYYY = XX::$yyy
Not 100% sure where the '$' goes.

You'll need to either make $yyy 'public' or make a function (getYYY() or a magic __get()) to retrieve the value.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
Post Reply