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

html - How to set bootstrap input responsive width? -

javascript - Highchart x and y axes data from json -

javascript - Get js console.log as python variable in QWebView pyqt -