I'm not sure exactly what your trying to do. I'm new here, so I'm not sure if my response is something your already very familiar with.
PHP: Visibility - Manual
Even if the function is public, you still have to create the class before the function is created (the parser doesn't parse a class until it is created).
Once it's created, you can call the function:
PHP Code:
print "TEST: " + $A->A1();
//Output == TEST A10
The "+" is a mathematical operator, and since the string "TEST:" has no integral value, it evaluates to 0. Use "." instead for strings.
PHP Code:
print "TEST: " . $A->A1();
//output == TEST A1TEST:
Since the function prints an output, and the function call in a print statement, it won't work like expected.
PHP Code:
$A->A1();
//output == TEST A1
So the whole script would be
PHP Code:
<?php
class A {
public function A1() {
print "TEST A1";
}
public function A2() {
print "TEST A2";
}
};
$A = new A();
$A->A1();
//TEST A1
?>
Once again I don't know your level of knowledge with PHP, so if this is something your already familiar with, let me know.