Preparse/preprocess PHP file ?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Sylvain Donnet

    #1

    Preparse/preprocess PHP file ?

    Hi,

    My question is probably entirely described in the subject... I need to
    preprocess a PHP file before it enters the PHP parser. My goal is to
    change some non-PHP parts of text into PHP orders. I see in PHP doc an
    output_handler to postprocess the output. And I see that there is no
    input_handler.

    Does anybody have a clue, a solution ? I am also looking for a solution
    outside PHP, in some Apache modules (for instance mod_transform, but I
    am not sure...).

    TIA

    Sylvain
  • Daniel Tryba

    #2
    Re: Preparse/preprocess PHP file ?

    Sylvain Donnet <sdonnet@ddo-org.com> wrote:[color=blue]
    > My question is probably entirely described in the subject... I need to
    > preprocess a PHP file before it enters the PHP parser. My goal is to
    > change some non-PHP parts of text into PHP orders. I see in PHP doc an
    > output_handler to postprocess the output. And I see that there is no
    > input_handler.[/color]

    What are you trying to do that can't be handled from within PHP? Is this
    per request or only once? Maybe at intervals (sou you can schedule it).

    BTW a quick and dirty way to do this within PHP is to rad the file into
    a string, modify it and than eval() it...

    --

    Daniel Tryba

    Comment

    • Manuel Lemos

      #3
      Re: Preparse/preprocess PHP file ?

      Hello,

      On 08/30/2004 07:10 PM, Sylvain Donnet wrote:[color=blue]
      > My question is probably entirely described in the subject... I need to
      > preprocess a PHP file before it enters the PHP parser. My goal is to
      > change some non-PHP parts of text into PHP orders. I see in PHP doc an
      > output_handler to postprocess the output. And I see that there is no
      > input_handler.[/color]

      Use the tokenizer extension:


      [color=blue]
      > Does anybody have a clue, a solution ? I am also looking for a solution
      > outside PHP, in some Apache modules (for instance mod_transform, but I
      > am not sure...).[/color]

      If you are looking for a templating solution, try Smarty:




      --

      Regards,
      Manuel Lemos

      PHP Classes - Free ready to use OOP components written in PHP
      http://www.phpclasses.org/

      PHP Reviews - Reviews of PHP books and other products
      http://www.phpclasses.org/reviews/

      Metastorage - Data object relational mapping layer generator

      Comment

      • Sylvain Donnet

        #4
        Re: Preparse/preprocess PHP file ?

        Manuel Lemos wrote:[color=blue]
        > Hello,
        >[/color]
        I already have found smarty and its template logics. I didn't know about
        tokenizer. Both are interesting, but I think I need batch processes to
        parse my PHP files. I am going to explain my goals by an example :

        I want to allow some HTML writers to write HTML files (in fact, PHP
        files, but not mandatory) and to include into them some markers, for
        instance : <phpoutput>.. .</phpoutput>, and when theses pages are
        rendered, theses markers are changed by PHP code : <?php echo .... ?>,
        BEFORE or EXACTLY WHEN theses pages entered the parser.

        Sylvain
        [color=blue]
        > On 08/30/2004 07:10 PM, Sylvain Donnet wrote:
        >[color=green]
        >> My question is probably entirely described in the subject... I need to
        >> preprocess a PHP file before it enters the PHP parser. My goal is to
        >> change some non-PHP parts of text into PHP orders. I see in PHP doc an
        >> output_handler to postprocess the output. And I see that there is no
        >> input_handler.[/color]
        >
        >
        > Use the tokenizer extension:
        >
        > http://www.php.net/tokenizer
        >[color=green]
        >> Does anybody have a clue, a solution ? I am also looking for a
        >> solution outside PHP, in some Apache modules (for instance
        >> mod_transform, but I am not sure...).[/color]
        >
        >
        > If you are looking for a templating solution, try Smarty:
        >
        > http://smarty.php.net/
        >
        >[/color]

        Comment

        • Ira Baxter

          #5
          Re: Preparse/preprocess PHP file ?


          "Sylvain Donnet" <sdonnet@ddo-org.com> wrote in message
          news:4133a5c9$0 $4376$626a14ce@ news.free.fr...[color=blue]
          > Hi,
          >
          > My question is probably entirely described in the subject... I need to
          > preprocess a PHP file before it enters the PHP parser. My goal is to
          > change some non-PHP parts of text into PHP orders. I see in PHP doc an
          > output_handler to postprocess the output. And I see that there is no
          > input_handler.
          >
          > Does anybody have a clue, a solution ? I am also looking for a solution
          > outside PHP, in some Apache modules (for instance mod_transform, but I
          > am not sure...).[/color]

          Might be overkill for your problem, but the DMS Software Reengineering
          toolkit can parse full PHP4 and PHP5, and carry out arbitrary
          transformations .
          See http://www.semanticdesigns.com/Produ...MSToolkit.html.


          --
          Ira D. Baxter, Ph.D., CTO 512-250-1018
          Semantic Designs, Inc. www.semdesigns.com


          Comment

          Working...