hrtehnolog Posted October 12, 2013 Share Posted October 12, 2013 Hi! php code copied form the book Begining php and MySQL (Apress) will not print: <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title></title> </head> <body> <?php class Book { // definicija polja private $title; private $isbn; private $copies; // konstruktor public function _construct($isbn) { $this->setIsbn($isbn); $this->getTitle(); $this->getNumberCopies(); } public function setIsbn($isbn) { $this->isbn = $isbn; } public function getTitle() { $this->title = "Beginning Python"; print "Title: ".$this->title."<br />"; } public function getNumberCopies() { $this->copies = "5"; print "Number copies available: ".$this->copies."<br />"; } } $book = new book("159059519X"); ?> </body> </html> Tried it on Turnkey LAMP and 000webhost, on several major browsers. Is something wrong? Thanks Quote Link to comment Share on other sites More sharing options...
Solution kicken Posted October 12, 2013 Solution Share Posted October 12, 2013 public function _construct($isbn) That should be: public function __construct($isbn) There are supposed to be two underscores in front. Quote Link to comment Share on other sites More sharing options...
hrtehnolog Posted October 12, 2013 Author Share Posted October 12, 2013 works now thanks a lot Quote Link to comment 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.