php - Defining variable in a class -


i new php, , i'm getting undefined variable $firstdect though defined:

class deck {     public function getdeck()     {         $firstdeck = new deck();         return $this->firstdeck;     } } 

and,

<div class="panel-body">     <?php foreach ($firstdeck->getdeck() $card): ?>         <img class="col-md-3" src="<?php echo $card->getimage(); ?>">     <?php endforeach; ?> </div> 

class deck {    /* have define variable below before        accessing $this->firstdeck     */    public $firstdeck;      public function getdeck()    {        $this->firstdeck = new deck();        return $this->firstdeck;    } } 

read more here


Comments

Popular posts from this blog

go - serving up pdfs using golang -

python - Best design pattern for collection of objects -

r - Using `bbmle:mle2` with vector parameters (already works using `optim`) -