|
Posted by Adam on 10/06/06 00:36
Hi everyone,
I figured by doing a larger project, I could start to learn how objects
and classes work in PHP, but I am running into a problem.
I am trying to write a sudoku generator. I was going to make a cell
class to hold the potential values of a cell...
class cell {
public $potentialValues = array(1,2,3,4,5,6,7,8,9);
}
Then a row class to hold and run functions of the cells in a row...
class row {
public $cell1 = new cell();
public $cell2 = new cell();
public $cell3 = new cell();
public $cell4 = new cell();
public $cell5 = new cell();
public $cell6 = new cell();
public $cell7 = new cell();
public $cell8 = new cell();
public $cell9 = new cell();
}
And finally a matrix class to hold all the rows...
class matrix {
public $row1 = &new row();
public $row2 = &new row();
public $row3 = &new row();
public $row4 = &new row();
public $row5 = &new row();
public $row6 = &new row();
public $row7 = &new row();
public $row8 = &new row();
public $row9 = &new row();
}
The problem is is that I guess I cannot use objects within another
class since this code errors. (Parse error: syntax error, unexpected
T_NEW in yadda/yadda/yadda.php). Could someone take a second to set me
right and kindly point me in the right direction? I have a feeling I
am just not looking at this problem correctly.
Thanks, Adam
Navigation:
[Reply to this message]
|