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"; ?> 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. 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 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
Archived
This topic is now archived and is closed to further replies.