I have this class ( it is simple card class):
class Card{
private $suit;
private $rank;
public function __construct($suit, $rank){
$this->$suit = $suit;
$this->$rank = $rank;
}
public function get_suit(){
return $this->$suit;
}
public function get_rank(){
return $this->$rank;
}
}
I instance every card ( with suit and rank) for deck :
$tmp_deck = array();
foreach ($SUITS as $suit){
foreach($RANKS as $rank){
array_push( $tmp_deck, new Card($suit, $rank) );
}
}
echo $tmp_deck[0]->get_suit();
And error it gives me :
Notice: Undefined variable: suit in card.php on line 13
I really cant get what is wrong. Can any one help me ?