ricky spires Posted October 17, 2011 Share Posted October 17, 2011 Hello, This is not something that im at a stage of putting to use but its on my mind. Is it possible to put a pages code into a database and pull out pages dynamically ??? so for example. if this was in a database id = (int) = 1 pageName = (varchar 255) = home code = (text) = <?php echo "hello world"; ?> how would i returning the code on a page ? "hello world" is simple but would you pull more complex code? i have seen examples of it working on social networks but have no idea how they do that. for example on Facebook pages "static FBML Iframes" they alow people to put in there own html but not php. anyway. just food for thought. would love to know the answer. thanks rick Quote Link to comment Share on other sites More sharing options...
StefanNET Posted October 17, 2011 Share Posted October 17, 2011 If I understood you well, you are looking for this function: http://php.net/manual/en/function.htmlentities.php with htmlentities your code wont be executed as php. Quote Link to comment Share on other sites More sharing options...
Psycho Posted October 17, 2011 Share Posted October 17, 2011 The only way to accomplish that would be to use eval() which is always a bad idea. A better solution would be to save the page (with PHP code) as a normal php page. Then use the database to dynamically determine the page to load. EDIT: maybe I misread your request. If you are just wanting people to be able to "save" code to be displayed as text, the htmlentities() are htmlspecialcharacters() is what you want. I thought you wanted to execute the code. Quote Link to comment Share on other sites More sharing options...
ricky spires Posted October 17, 2011 Author Share Posted October 17, 2011 no, your right. i was thinking of executing the code. i was thinking to use it in a template system. so the nav calls the page id from the database and execute the code for the page that is stored in the database. i thought it might be a good way the build a site without having 100s of php files. never mind. just a thought i had Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.