I have admin panel in which I can create categories. When I create categories I auto create folders in htdocs… for example… categorie/first , categorie/second and so on
And what I want to do, is that when I create these folders I auto create index.php with code I need… First variant is using file functions… but then how do I put in string php commands?
second.. and I guess the right one, is to create this template.. and when I create these folders it copies to directory I created…
So what you think?
edit…
BUT I need to store in this code variable with current categorie opened.
One solution is to write your code like that :
Remeber to put EOT; at the very left side of your document. See the heredoc syntax for details.
This code is a sample, you need of course to check if fopen/fwrite have succeeded.
Another solution could be to have a template in another file with template tokens.
In such way, you will have a file named template_category.txt which contains :
Then, in your PHP script, you’ll do replace template tokens by your values :
And you write $page on index.php like above.