getting error "Parse error: syntax error, unexpected '$physics' (T_VARIABLE), expecting function (T_FUNCTION) in C:\xampp\htdocs\bookclass.php on line 19"need help pls help me out.

<?php
class  Books{
    /* Member variables */
    public $price;
    public $title;
    /* Member functions */
    function setPrice($par){
       $this->price = $par;
    }
    function getPrice(){
       echo $this->price ."<br/>";
    }
    function setTitle($par){
       $this->title = $par;
    }
    function getTitle(){
       echo $this->title ." <br/>";
    }
  $physics = new Books;
  $physics->setTitle( "Physics for High School" );
  $physics->setPrice( 10 );
  $physics->getTitle();
  $physics->getPrice();
}
?>

In line 19 you have code inside the class but outside any method . Probably you meant to close the class first and then use it.

thanks for ur reply, it worked out.thanks.

I don't know whether your codes are just for training purposes but for production purposes declare the state of your methods, be it, public, private or protected

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.