I am not able to get output with this code

I am new to php, I am not able to see text output, please help me, what’s wrong with this code

<?php class Books{ /* Member Variable*/ var $price; var $title; /* Member Function*/ function setPrice($par){ $this->price = $par; } function getPrice(){ echo $this->price ."
"; } function setTitle($par){ echo $this->title = $par; } function getTitle(){ echo $this->title ."
"; } } function _construct( $par1, $par2 ) { $this->title = $par1; $this->price = $par2; } $history = new Books("History Book", 10); $history->getTitle(); $history->getPrice(); ?>

There are errors in the code. Your class constructor isn’t even in the class. And the constructor name is incorrect.

Thanks, works for me :slight_smile:

Sponsor our Newsletter | Privacy Policy | Terms of Service