Storing/Retrieving/Executing Php

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Ankur Gupta

    Storing/Retrieving/Executing Php

    I want to creating an application where all my php(with html) is stored in the database.
    So my index.php would find the appropriate the php file associated with the index page. It should execute this new code
    as part of the original index.php. Can you please let me know if it is doable?


    Thanks,


    --
    -Ankur Gupta
  • powerboy

    #2
    Re: Storing/Retrieving/Executing Php

    "Ankur Gupta" <agupta@cc.gate ch.edu> wrote in message
    news:bir78l$lvg $1@solaria.cc.g atech.edu...[color=blue]
    > I want to creating an application where all my php(with html) is[/color]
    stored in the database.[color=blue]
    > So my index.php would find the appropriate the php file associated[/color]
    with the index page. It should execute this new code[color=blue]
    > as part of the original index.php. Can you please let me know if it[/color]
    is doable?

    Yes this is doable with http://php.net/eval

    Why you would want to do something like that I'm not sure - a database
    would be more suited to storing the data as opposed to the code.


    Comment

    • Nikolai Chuvakhin

      #3
      Re: Storing/Retrieving/Executing Php

      Ankur Gupta <agupta@cc.gate ch.edu> wrote in message
      news:<bir78l$lv g$1@solaria.cc. gatech.edu>...[color=blue]
      >
      > I want to creating an application where all my php(with html)
      > is stored in the database. So my index.php would find the
      > appropriate the php file associated with the index page. It
      > should execute this new code as part of the original index.php.
      > Can you please let me know if it is doable?[/color]

      Yes. Read about the eval() function; you will have to use it
      extensively:



      Cheers,
      NC

      Comment

      • Ankur Gupta

        #4
        Re: Storing/Retrieving/Executing Php

        powerboy <powerboy@rarex treme.com> wrote:
        : "Ankur Gupta" <agupta@cc.gate ch.edu> wrote in message
        : news:bir78l$lvg $1@solaria.cc.g atech.edu...
        :> I want to creating an application where all my php(with html) is
        : stored in the database.
        :> So my index.php would find the appropriate the php file associated
        : with the index page. It should execute this new code
        :> as part of the original index.php. Can you please let me know if it
        : is doable?

        : Yes this is doable with http://php.net/eval

        : Why you would want to do something like that I'm not sure - a database
        : would be more suited to storing the data as opposed to the code.

        The idea is to have bunch of templates and associate them with a page. So for instance,
        each user can have totally different looking index page based on their preferences.

        So when a user is directed to a index.php page. This page would have the code
        to find an appropriate template and render it.

        I am still having problems with using eval function though. Here's what I am trying to do:

        <?php
        $var = "2344";
        $phpCode = '<html><body><? php echo $var; ?> </body></html>';
        echo $phpCode. "\n";
        eval ("\$phpCode = \"$phpCode\";") ;
        echo $phpCode. "\n";
        ?>


        No output why??


        Thanks,

        --
        -Ankur Gupta

        Comment

        Working...