I want to require/include a content from database record, but require/include only accepts files. This thing is related to caching, so I dont want to write anything to file (collisions etc). How to dodge it?
I want to require/include a content from database record, but require/include only accepts files.
Share
Since others have covered
eval()and the fact that this is a bad idea, I will touch on the topic of writing this “content” to a file. Usetempnam. This will give you the name of a just-created unique filename with 0600 permissions. You can then open it, write your content, close, then require/include. See Example #1 on thetempnamman page.Make sure to check that the return value of
tempnamis not false; make sure tounlinkthe file after you are done.