Jump to content
Larry Ullman's Book Forums

Recommended Posts

abstract class Shape
	// No attributes to declare
	// No constructor or destructor defined here
	// Method to calculate and return the area.
	abstract protected function getArea();
	// Method to calculate and return the perimeter.
	abstract protected function getPerimeter();
// End of Shape class.

Next I declared "Triangle" class

class Triangle extends Shape
	// Declare the attributes:
	private $_sides = array();

Then created the "abstract.php"

<!DOCTYPE html>

<html lang="en">
		<meta charset="utf-8">
		<link href="css/style.css" rel="stylesheet">
	# Script 6.3 - abstract.php
	// This page uses the Triangle class (Script 6.2), which is derived
	// from Shape (Script 6.1).
	// Load the class definitions
	// Set the triangle's sides:
	$side1 = 5;

When I run abstract.php, it generates the following error

Fatal error: Class 'Shape' not found in C:~\Triangle.php on line 15

I don't understand why it's showing this error. Please help!

My PHP version is 5.6.12 using XAMPP Version 5.6.12

Edited by alex_r
Link to comment
Share on other sites

Am not sure what happened too. 

I tested using "include", which worked and later i used "require" and now seems to work fine no problem. I don't know what the problem is.

	// Load the class definitions
Link to comment
Share on other sites


  • Create New...