hi,
hopefully someone will be able to steer me in the right direction. i'm a c++ programmer normally and i'm having a little problem with the way php includes classes.
i'm trying to include two class definitions into a third php script. if necessary, i can include the entire code, but here's what i'm currently doing conceptually:
this is a file called "MyClass.php"
<?php
class MyClass
{
var $variable;
/* constructor */
function MyClass ($value)
{
$this->variable = $value;
}
function aSampleFunction($value)
{
/* do something with $value */
$this->variable = MyClass::anotherFunction($value);
}
function anotherFunction($value)
{
/* do something with $value */
return $value;
}
}
?>
i also have a similar class, let's call it "MyOtherClass.php".
these two classes are included in a script like so:
<?php
include_once("MyClass.php");
include_once("MyOtherClass.php");
$class = new MyClass($someValue);
$otherClass = new MyOtherClass($anotherValue);
?>
as i said, this is only a simplified version and i can include the code if necessary (but it's very long and mostly irrelevent).
this code results in "Fatal Error: Cannot redeclare class myotherclass"
my gut feeling is that there might be something wrong with the MyClass::anotherFunction($value) notation. am i implementing this correctly? i've also tried $this->anotherFunction($value) instead but it made no difference. but as far as i know, i'm doing that correctly.
are there any issues i should be aware of when trying to include class definitions? i have made sure to use include_once. also, i thought maybe i chose class names that php already implemented internally so for debugging purposes i changed my class names to long, silly and unlikely ones, yet the problem persists.
any help would be much obliged.