Inserting values to files, similar to templates

This is a discussion on Inserting values to files, similar to templates within the alt.comp.lang.php forums, part of the PHP Programming Forums category; Hello, I don't need the code or anything, just the idea. My project will generate a file with PHP ...


Go Back   Usenet Forums > PHP Programming Forums > alt.comp.lang.php

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 05-27-2005
Hello
 
Posts: n/a
Default Inserting values to files, similar to templates

Hello,

I don't need the code or anything, just the idea.

My project will generate a file with PHP code. It is being done by
getting a standard PHP file that acts like a template for future PHP
generated files. However, there are some portions that will be changed in
the newly generated PHP files.

How would I approach this efficiently so I could insert a different code
into PHP template and save it as a different file?

Do I put some kind of a tag then open the template, search for the tag and
replace it?

Or, do I put in string values parts of the code that don't change then I put
them together with the changes values in between?

I want it to be less messy since the template might be changed one day.

Thank you.


Reply With Quote
  #2 (permalink)  
Old 05-27-2005
Colin McKinnon
 
Posts: n/a
Default Re: Inserting values to files, similar to templates

Hello spilled the following:
>
> I don't need the code or anything, just the idea.
>
> My project will generate a file with PHP code. It is being done by
> getting a standard PHP file that acts like a template for future PHP
> generated files. However, there are some portions that will be changed in
> the newly generated PHP files.
>
> How would I approach this efficiently so I could insert a different code
> into PHP template and save it as a different file?
>
> Do I put some kind of a tag then open the template, search for the tag and
> replace it?
>
> Or, do I put in string values parts of the code that don't change then I
> put them together with the changes values in between?
>


Don't rewrite the file use 'include'/'require' instead. Alternatively go
look at the existing template systems - although they are exclusively
targeted at implementing a consistent look and feel, the funcionality in
them may be exactly what you need.

Third approach is to create a self-modifying system. Although PHP has some
great features for developing such systems and code generators, you need to
be VERY careful taking this approach.

HTH

C.
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 08:48 AM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0