You need to get an instance of the anotherClass and run the function off that. In your example, $this->testFunction() is trying to use the function in WC_Payment_Gateway.
You want something like:
class anotherClass{
public function testFunction(){
echo "This is the test function";
}
}
class Test extends WC_Payment_Gateway{
$anotherClass = new anotherClass;
$anotherClass->testFunction();
}
Although whether that is specifically correct for you would depend on what exactly anotherClass is and does.
I get a
Fatal error: Class ‘anotherClass’ not found
Have you actually loaded the class anywhere? You need to make sure the file that holds you class is included somewhere.
Yep I have
include(‘Test/src/anotherClass.php’);
I added
include plugins_url( 'test/classes/Test/anotherClass.php' );
but I’m getting this error
Warning: include(): http:// wrapper is disabled in the server configuration by allow_url_include=0 in C:\wamp\www\wordpress\wp-content\plugins\test\classes\test.php on line 226
Line 226 is where the include is.
Your server (probably wisely) doesn’t support loading a PHP file with a URL. So don’t use plugins_url to get the location of the file, use plugin_dir_path() instead.
I’ve included the file, but I’m still getting the Class ‘anotherClass’ not found
We’re getting into learning basic PHP here, so you probably want to go to somewhere like stackoverflow.com, but can you share all the code you’ve got so far?