【问题标题】:Generate a PHP file in PHP [closed]在 PHP 中生成 PHP 文件 [关闭]
【发布时间】:2015-12-07 03:02:19
【问题描述】:

我如何创建一个 PHP 脚本来生成 PHP 文件,它就像一个表单或其他东西。我对这件事很陌生。请帮忙。我希望它生成这种格式的文件:

<?php
$infolink = 'http://minecraft.net';
$downloadlink = '***';
$ttext = 'Minecraft';
$ctext = 'Minecraft is a game about breaking and placing blocks. At first, people built structures to protect against nocturnal monsters, but as the game grew players worked together to create wonderful, imaginative things.';
$text = '
Minecraft is a game about breaking and placing blocks. At first, people built structures to protect against nocturnal monsters, but as the game grew players worked together to create wonderful, imaginative things.
It can also be about adventuring with friends or watching the sun rise over a blocky ocean. It’s pretty. Brave players battle terrible things in The Nether, which is more scary than pretty. You can also visit a land of mushrooms if it sounds more like your cup of tea.';
$video = 'XAj1acQ_CE4';
$background = 'https://pmcdeadline2.files.wordpress.com/2014/02/minecraft__140227211000.jpg';
?>

【问题讨论】:

  • 一个php文件只是另一个文本文件。
  • 字符串弄乱了
  • 一个文件中的一个表格,我使用了默认的写入方法,我会再试一次
  • 我将使用批处理文件来生成该文件,我将使用 php 上传它
  • 我认为您需要的只是重新访问您的文件创建代码并查看文本实际混乱的位置,尝试使用this 之类的方法进行调试。

标签: php html forms


【解决方案1】:

PHP 文件只是一个文本文件。

<?php
$myfile = fopen("newfile.php", "w") or die("Unable to open file!");
$txt = "<?php your PHP codes\n";
fwrite($myfile, $txt);
$txt = "more php codes\n";
fwrite($myfile, $txt);
$txt = "?>";
fwrite($myfile, $txt);
fclose($myfile);
?>

我回答了您的问题,但是您的方法似乎完全错误!

【讨论】:

    猜你喜欢
    • 2018-09-01
    • 2010-09-16
    • 2023-03-31
    • 2010-09-28
    • 2013-11-09
    • 1970-01-01
    • 2014-10-05
    • 2016-03-07
    相关资源
    最近更新 更多