[英]Saving php code into a file without interpreting it
如何使用 PHP 将 php 脚本/代码保存到文件中,而无需在保存之前解释 PHP 脚本。
$_POST['posted_code'] = "<html> some cool text <?php print 'Hi, i cant be saved because am being interpreted'; ?> <img> <script></script> <?php include('file'); ?></html>";
我试过了
header('Content-Type: text/plain;');
file_put_contents('new_file.php',$_POST['posted_code']);
但是我登陆了 403 禁止,并且没有 php 脚本,它正在保存。
我该如何解决这个问题,以便以以后解释的方式保存代码
您能否将您的张贴代码用单引号括起来,例如“张贴代码”。
试试下面的代码,它将您的 php 脚本/代码保存到文件中,而不解释 PHP 脚本
$_POST['posted_code'] = "<html> some cool text <?php print 'Hi, i cant be saved because am being interpreted'; ?> <img> <script></script> <?php include('file'); ?></html>";
也在此处进行更改
header('Content-Type: text/plain;');
file_put_contents('new_file.php',$_POST['posted_code']);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.