Imtiyaaz Posted April 3, 2012 Share Posted April 3, 2012 Hi Can anyone tell me why this code is not displaying anything besides book: Im new to OOP in php and need some help getting the following to run properly <?php class ShopProduct{ public $title = "Where eagles dare"; public $producerMainName = "McLean"; public $producerFirstName = "Alistair"; public $price = 179; function getProducer(){ return "{$this->producerFirstName}"; "{$this->producerMainName}"; } } $product1 = new ShopProduct(); $product1->title=""; $product1->producerMainName=""; $product1->producerFirstName=""; $product1->price=""; print "Book: {$product1->getProducer()}\n"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/260271-code-not-siplaying-any-info/ Share on other sites More sharing options...
scootstah Posted April 3, 2012 Share Posted April 3, 2012 Because you set the names to empty values. Quote Link to comment https://forums.phpfreaks.com/topic/260271-code-not-siplaying-any-info/#findComment-1333999 Share on other sites More sharing options...
Imtiyaaz Posted April 3, 2012 Author Share Posted April 3, 2012 Thanks Quote Link to comment https://forums.phpfreaks.com/topic/260271-code-not-siplaying-any-info/#findComment-1334001 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.