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

networking - Vagrant-provisioned VirtualBox VM is not reachable from Ubuntu host -

c# - ASP.NET Core - There is already an object named 'AspNetRoles' in the database -

ruby on rails - ArgumentError: Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true -