|
Posted by Colin McKinnon on 05/28/05 00:43
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.
[Back to original message]
|