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

python - Best design pattern for collection of objects -

go - serving up pdfs using golang -

python - django admin: changing the way a field (w/ relationship to another model) is submitted on a form so that it can be submitted multiple times -