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 ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
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. |
|
|||
|
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. |
![]() |
| Thread Tools | |
| Display Modes | |
|
|