Christian
Christian

Reputation: 111

"Copy" a php-file and include the POST-variable

I work on a PHP-app with some live functions etc. I have created a PHP script that does the following:

Then my problem is - I need script to create two files with a specific content - but the variable called from the form input must be included so it calls from the specific (here) JOHN-table in the database.

I tried just to copy - but it requires to manually edit the file. As there'll be unlimited tables created, I don't want to do this. :)

I then tried to make the script create a new file. Worked - except it can't include PHP-variables or tags - which makes sense, of course, but I am stuck now. :(

Can anyone help?

Upvotes: 0

Views: 408

Answers (2)

flowfree
flowfree

Reputation: 16462

Nanne's answer is the way to go. But if you really curious about this, of course you can write the code to edit the script.

  1. Copy the master PHP file to user specific PHP file
  2. Get the contents of the newly created file
  3. Replace all variables with str_replace. Maybe something like this:

    $contents = str_replace('$name = "NAME"', '$name = "John"', $contents)

  4. Save the contents back to the file.

Upvotes: 1

Nanne
Nanne

Reputation: 64419

  • save all the instance-specific data to a central database.
  • Have all your instances query that database for their specific variables like databasename, root folder etc

Upvotes: 1

Related Questions