Monica22 Posted November 15, 2013 Share Posted November 15, 2013 Hi I am new to this site and was hoping to get a little help. I am in the learning stages and creating an object-oriented programming using php. I have two files, an idex file and a vehicle.php file. I keep getting the following errors: Parse error: syntax error, unexpected ';', expecting T_FUNCTION in/home/msj03/html/lis5367/lib/vehicle.php on line 92 The last line, the one in red is line 92- can anyone help? Thanks, <?php //define class class vehicle1 { //private properties (class variables) private $vin; private $manufacturer; private $type; private $color; private $price; //public methods/functions //default constructor public function __construct($vin="12345678901234567", $manufacturer="Toyota", $type="Tundra", $color="White", $price=25000) { $this->vin = $vin; $this->manufacturer = $manufacturer; $this->type = $type; $this->color = $color; $this->price = $price; } function __destruct() { //unset($this); echo "Destroying " . $this->vin . "<br />"; } //value-returning functions //getter methods/functions (get object's properties) public function getvehicle1() { return $this->vin . " " . $this->manufacturer . " " . $this->type . " " . $this->color . " " . $this->price . " " ; } public function getvin() { return $this->vin; } public function getmanufacturer() { return $this->manufacturer; } public function gettype() { return $this->type; } public function getcolor() { return $this->color; } public function getprice() { return $this->price; } //setter methods/functions (set object's properties) public function setvin($vin) { $this->vin = $vin; } public function setmanufacturer($manufacturer) { $this->manufacturer = $manufacturer; } public function settype($type) { $this->type = $type; } public function setcolor($color) { $this->color = $color; } public function setprice($price) { $this->price = $price; }//end class ?> Quote Link to comment Share on other sites More sharing options...
mac_gyver Posted November 15, 2013 Share Posted November 15, 2013 your last class method/function is missing its closing } i recommend that when writing code that you use indentation so that the {} that belong together are at the same indentation level. Quote Link to comment Share on other sites More sharing options...
Monica22 Posted November 15, 2013 Author Share Posted November 15, 2013 Thanks... Quote Link to comment Share on other sites More sharing options...
Monica22 Posted November 18, 2013 Author Share Posted November 18, 2013 A little more help if possible... My page is not giving me line breaks- any idea why? <?php include('../lib/vehicle.php'); $vehicle1 = new vehicle(); $vehicle2 = new vehicle("122445566778899", "Ford", "Edge", "Black", 50000); echo "<b>Returning Vehicle Properties:</b><br> />"; echo "<b> Vehicle 1:</b>"; echo "Vin:" . $vehicle1->getvin() . " "; echo "Manufacturer:" . $vehicle1->getmanufacturer() . " "; echo "Type:" . $vehicle1->gettype() . " "; echo "Color:" . $vehicle1->getcolor() . " "; echo "Price:" . $vehicle1->getprice() . " "; echo "<b> Vehicle 2:</b> "; echo "Vin:" . $vehicle2->getvin() . " "; echo "Manufacturer:" . $vehicle1->getmanufacturer() . " "; echo "Type:" . $vehicle2->gettype() . " "; echo "Color:" . $vehicle2->getcolor() . " "; echo "Price:" . $vehicle2->getprice() . " "; echo "<b> Vehicle2 (After Changing Property Values):</b> "; echo "Vin:" . $vehicle2->getvin() . " "; echo "Manufacturer:" . $vehicle1->getmanufacturer() . " "; echo "Type:" . $vehicle2->gettype() . " "; echo "Color:" . $vehicle2->getcolor() . " "; echo "Price:" . $vehicle2->getprice() . " "; "<br />"; ?> Quote Link to comment Share on other sites More sharing options...
Monica22 Posted November 18, 2013 Author Share Posted November 18, 2013 So basically my vehicle 1 & vehicle 2 lines are all running together... Quote Link to comment Share on other sites More sharing options...
AaronClifford Posted November 18, 2013 Share Posted November 18, 2013 (edited) <?php include('../lib/vehicle.php'); $vehicle1 = new vehicle(); $vehicle2 = new vehicle("122445566778899", "Ford", "Edge", "Black", 50000); echo "<b>Returning Vehicle Properties:</b><br />"; echo "<b> Vehicle 1:</b>"; echo "Vin:" . $vehicle1->getvin() . " "; echo "Manufacturer:" . $vehicle1->getmanufacturer() . " "; echo "Type:" . $vehicle1->gettype() . " "; echo "Color:" . $vehicle1->getcolor() . " "; echo "Price:" . $vehicle1->getprice() . " "; echo "<br />"; echo "<b> Vehicle 2:</b> "; echo "Vin:" . $vehicle2->getvin() . " "; echo "Manufacturer:" . $vehicle1->getmanufacturer() . " "; echo "Type:" . $vehicle2->gettype() . " "; echo "Color:" . $vehicle2->getcolor() . " "; echo "Price:" . $vehicle2->getprice() . " "; "<br />"; echo "<b> Vehicle2 (After Changing Property Values):</b> "; echo "Vin:" . $vehicle2->getvin() . " "; echo "Manufacturer:" . $vehicle1->getmanufacturer() . " "; echo "Type:" . $vehicle2->gettype() . " "; echo "Color:" . $vehicle2->getcolor() . " "; echo "Price:" . $vehicle2->getprice() . " "; "<br />"; ?> I personally wouldn't mix it up all up like this but the above should work, you didn't have a line break between the two cars. Edited November 18, 2013 by AaronClifford Quote Link to comment Share on other sites More sharing options...
Monica22 Posted November 18, 2013 Author Share Posted November 18, 2013 Thank you sooo much... that helps me 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.