but I'm still unsure about things such as naming conventions for the class file.
There arent any enforced naming conventions for filenames.
In fact, you could even treat .html files as PHP files, if you configured the webserver to do so.
I have also tried naming the file Test.inc.
Unless your webserver is configured to treat .inc files as PHP files, that usually isnt a good idea.
Just stick to .php, or perhaps to .inc.php or .class.php (since then the extension is still actually .php)
Let's do a test with 2 files, test.php and class.php, which we shall place in the same directory to simplify matters:
<?php
//test.php
require 'class.php';
if (class_exists("Foo")) {
$bar = new Foo("Hello World!");
echo $bar->announce();
} else {
echo "Class 'Foo' does not exist!";
}
?>
<?php
//class.php
class Foo {
var $announcement;
function Foo($a = '') {
$this->announcement = $a;
}
function announce() {
return $this->announcement;
}
}
?>
Run test.php and see what you get.