Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Nov 2003
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    using php to write php...

    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...);
    $menu->output();

    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

    Cheers

  • #2
    Supreme Overlord Spookster's Avatar
    Join Date
    May 2002
    Location
    Marion, IA USA
    Posts
    6,280
    Thanks
    4
    Thanked 83 Times in 82 Posts
    It's all in the manual

    http://us2.php.net/eval
    Spookster
    CodingForums Supreme Overlord
    All Hail Spookster

  • #3
    New to the CF scene
    Join Date
    Nov 2003
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    using php to write php...

    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

    Chris

  • #4
    Senior Coder missing-score's Avatar
    Join Date
    Jan 2003
    Location
    UK
    Posts
    2,194
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •