dongqi8030 2012-05-21 11:11
浏览 28
已采纳

“复制”一个php文件并包含POST变量

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

  • Based on a form input, it creates a folder with the input name, eg. JOHN. (called $dir)
  • It then creates a MySQL database table with the name the prefix_JOHN.
  • It then copies and moves the system templates files to the JOHN-folder.

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?

  • 写回答

2条回答 默认 最新

  • douxun4924 2012-05-21 12:15
    关注

    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.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 stata安慰剂检验作图但是真实值不出现在图上
  • ¥15 c程序不知道为什么得不到结果
  • ¥40 复杂的限制性的商函数处理
  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题