Using eval will work, but I was hoping there is more natural way of achieving the result.
Lets suppose I need to connect to the database. I have a class DB that does it. So every time I need a db connection somewhere i would have to write
new DB(x,y,z)
Instead I keep x,y,z in an array in a config file. The same applies to every class which constructor parameters can be written to a config file before script runs. Then I could request DB object from a part of script which would automatically get DB connection parameters from config, and use them to create an object. When I want an object of another class, then the same part of script would find appropriate parameters in config and use them to create desired object.
I tried to do similar thing with singletons but I don't want to make any changes in classes.