Technically yes you can, you could call eval($insertPlugin);
to run the code stored in a string. You would need to use single quotes to prevent the $Insert variable being converted into a string when you set the $insertPlugin variable.
However This is generally considered evil (particularly if your code is constructed from user input) See here: When is eval evil in php?
It depends on what you actually want to vary in your "plugin" as to what the correct approach would be. One approach would be to create a class that encapsulates the functionality you want.
class Command{
private $inserter;
public function __constructor($inserter){
$this->inserter=$inserter;
}
public function run(){
$this->inserter->insert_test('abc', '123');
}
}
$command = new Command(new Insert());
$something =1;
if($something >0)
{
$command->run();
}
Another would be to use lambda functions:
$insertPlugin=function() use ($Insert) {
$Insert->insert_test('abc', '123');
};
$something =1;
if($something >0)
{
$insertPlugin();
}
It sounds like you should probably do some more reading on OOP - I think what you basically want is a 'Command' class http://www.fluffycat.com/PHP-Design-Patterns/Command/ see in particular the use of an abstract class to allow you to define multiple different commands (or "plugins" as you called it)