KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I'm from a Java background, and I want to use an inner class in php. Every time I put the inner class though, I get a syntax error. Is this possible with PHP? Also, how do I reference the outer class? Do I get access to ALL its data members? <?php class OuterClass { var $x = 15; function __construct() { } class InnerClass { // error when InnerClass is static function __construct() { // error when InnerClass is static echo $x; } } } ?> This is used for a MoveClass (as in make a move) of a specific card game. I think it'd be good design to put these classes together because they don't make sense apart. Also, the MoveClass needs to know about some data members of the Game class. Why not make it a function? It's simply too big. Edit: What about nested classes? From what I understand, those have to be static? O_o
Tags (comma-separated)
Save Edits
Cancel