Hi, I got a question. How can one write a php file to manipulate a php file?
What I am saying is how can I create PHP code that will allow me to generate a PHP file with working code inside it.
Yet, allow me to still manipulate that file.
I do know how to open files or create new ones and open and read them and write them. Do know how to use regular expressions. Yet, I never learned how I can structure the file to allow me to generate a working php file and then after be able to manipulate it vie my php code.
I don't want to manually dive into my files to hand code things. I was thinking more of using or running fuctions that create php functions or php code and then I can dump them into a file and make it a php file. Then later on I can go inside the file and delete parts. Like lets say I decide to change the functions condition to run such code. instead of deleting that whole line of code. I would like to be able to find that line and then know exactly where on that line is the function or if statement I meant if statement to search for that if statement and change the conditions inside that if statement. So anything inbetween () I will delete and then add a new set of conditions.
How can one do this? never found anything in the internet about how to do such a thing. I right now able to generate a PHP page on the fly. I have a webpage on my website where It gives you buttons. Based on pressing these buttons it overwrites that page file. It would show the page as how you wanted it to look like.
So, I know it's possible to create PHP and then save it to a file that you make it a PHP file and then run it. I right now am able to do that.
The part that gets me puzzled is manipulating the file. I don't know how I can find the exact line or code.
for example the if statement. If I use regular expressions. I would think in a php file their would be more then one if statement. So I don't understand how I can narrow down to be able to know line by line character by charter where everything is so I can just delete what is needed and just replace what is needed.
Page 1 of 1
1 Replies - 3048 Views - Last Post: 20 February 2012 - 10:34 AM
Replies To: How to manipulate php files?
Re: How to manipulate php files?
Posted 20 February 2012 - 10:34 AM
itís not worth the trouble. besides that, if you need to write code to create the actual code, then you can write the actual code right away. you may use frameworks to ease the tedious work of standard tasks (such as fetching data from a database) but thatís a completely different level than what you describe.
Page 1 of 1