View Full Version : using php to write php...

11-06-2003, 04:15 PM
Having downloaded phpdev recently and played with it for about a week I'm intoxicated. so much better than perl (for a c programmer).

What I'd like to do with php though is use it to make creating web pages/sites really quick and easy (sort of by shorthanding repeated sections). Specifically I'd want to create php class objects that represent items on my webpage and have output methods so you can do

$menu = new myMenu( ...args...);

and store my web site layout in a database or xml file.

a master php script would read the page configuration, and output the php for the page (which in turn would run and output the html for the page).

So that's basically my question : Is is possible to write a php page that when 'executed' echo/prints php code that is then itself executed ?

Any help/ideas would be well received


11-06-2003, 04:19 PM
It's all in the manual


11-06-2003, 09:56 PM
Cool thanks. :) shoulda guessed (do it all the time in javascript).

was hoping that I could basically get html from the database and 'eval' that, but this needs valid php. not a biggie though, simple string processing will let me pick out the php and non php parts.

Thanks again


11-06-2003, 11:31 PM
i dont know if this would work for you, but i think the fastest way, or at least the way i would do it, would be:

have a php file with your html template.

within the php file, load the database information and only store the php code in the database.

eval the code and then you have your output.

i dont know if this would suit you, but it seems a faster way of processing as well as using up less database space.