Huge problem - Need to parse/complile a string and return as string

I’m trying to load a php file into another php file but I need that first file to be parsed (meaning all the variables within it get assigned values from a db) before it gets loaded into its parent file.

I’ve been looking for a good 3-4 hours. I have tried eval(), compile(), and pretty much everything in the book (php.net).

Please, anyone, can you help me? Is there even a function that does this?