You can do it, but it goes against one of the main benefits of OOP: keeping your code as modular and loosely coupled as reasonably possible. By calling a user-defined function within your class, you now create a dependency between that class and the separate function definition, with nothing in the class's template indicating there is such a dependency.
It might make more sense for that separate function to be either within its own class or - perhaps more likely - grouped together with related functions as methods within some class of their own. Then you would pass that class to the other class, therefore making it explicit in that second class's interface that it depends on that other class.
class Utilities
{
function myFunction()
{
echo "Hello, World.";
}
}
class DemoClass
{
protected $utils;
public function __construct(Utilities $util)
{
$this->utils = $utils;
}
public example()
{
$this->utils->myFunction();
}
}
$test = new DemoClass(new Utilities());
$test->example(); // should output "Hello, World."