Update:
If you are using PHP 5.3 or higher, see other answers, please :)
I don't think the correct syntax is, this will give you:
Parse error: syntax error, unexpected T_FUNCTION in....
You need to create a class, add a method to it, use the keyword newto create it, and then you can:
$ar->a();
class myclass
{
public function a()
{
echo 'TEST';
}
}
$ar = new myclass;
$ar->a();
See Classes and objects for more details .
source
share