我想知道是否可以在PHP文档上打印或回显代码,以便它始终打印不同的代码?所以基本上我想为显示的每个惩罚创建一个不同的按钮,但是该按钮带有一个带有该按钮ID的表单,我如何使用该ID激活某种代码以便做任何事......
print " <div class='modal fade' id='pun-$id' tabindex='-1' role='dialog' aria-labelledby='$id' aria-hidden='true'>";
print " <div class='modal-dialog'>";
print " <div class='modal-content'>";
print " <div class='modal-header'>";
print " <button type='button' class='close' data-dismiss='modal' aria-hidden='true'>×</button>";
print " <h4 class='modal-title'>Punishment record of $username</h4>";
print " </div>";
print " <div class='modal-body'>";
print " <ul class='list-group'>";
print " <li class='list-group-item'>Punishment ID: </br><div class='well well-sm'><p>"; print $row[0]; print "</p></div></li>";
print " <li class='list-group-item'>Punishment Type: </br><div class='well well-sm'><p>"; print $row[11]; print "</p></div></li>";
print " <li class='list-group-item'>Date Punished: </br><div class='well well-sm'><p>"; print $row[5]; print "</p></div></li>";
print " <li class='list-group-item'>Punished until: </br><div class='well well-sm'><p>"; print $row[6]; print "</p></div></li>";
print " <li class='list-group-item'>Punished by: </br><div class='well well-sm'><p>"; print $punisher[0]; print "</p></div></li>";
print " <li class='list-group-item'>Reason: </br><div class='well well-sm' style='height: 150px; overflow: auto;'><p>"; print $row[3]; print "</p></div></li>";
print " <li class='list-group-item'>Link to the evidence: </br><div class='well well-sm'><p>"; print $row[4]; print "</p></div></li>";
print " </ul>";
print " <hr>";
print " <ul class='list-group'>";
print " <li class='list-group-item'>Revoked Reason: </br><div class='well well-sm'><p>"; print $row[9]; print "</p></div></li>";
print " <li class='list-group-item'>Revoked by: </br><div class='well well-sm'><p>"; print $row[10]; print "</p></div></li>";
if($row[8] == 0 && $_permission >= $_SETTINGS['permission_required-revoke-punishment']) {
print " <button data-toggle='modal' href='#revoke-$id' style='padding: 10px; border: 0; width: 100%; margin-top: 10px;' class='btn btn-primary' data-dismiss='modal'>Revoke Punishment</button>";
} else {
print " <button data-toggle='modal' href='#revoke-$id' style='padding: 10px; border: 0; width: 100%; margin-top: 10px;' class='btn btn-primary disabled' data-dismiss='modal'>Revoke Punishment</button>";
}
print " </ul>";
print " </div>";
print " </div>";
print " </div>";
print " </div>";
$code = '<?php
if(isset($_POST[\'revoke_pun-$id\'])) {
$reason = $_POST[\'reason-$id\'];
$reason = stripslashes($reason;
$reason = $connection->real_escape_string($reason);
$command = "UPDATE $punishments SET REVOKED=1, REVOKE_REASON=$reason, REVOKER_ID=$uid WHERE PUNISHMENT_ID = $id;";
mysqli_query($connection, $command) or die (mysqli_error());
}
?>';
print "<div class='modal fade' id='revoke-$id' tabindex='-1' role='dialog' aria-labelledby='revoke-$id' aria-hidden='true'>";
print " <div class='modal-dialog'>";
print " <div class='modal-content'>";
print " <div class='modal-header'>";
print " <button type='button' class='close' data-dismiss='modal' aria-hidden='true'>×</button>";
print " <h4 class='modal-title'>Revoke Punishment</h4>";
print " </div>";
print " <div class='modal-body' style='padding-bottom: 50px;'>";
print " <form role='form' method='post'>";
print " <textarea style='resize:vertical; min-height: 100px; margin-bottom: 10px;' class='form-control' placeholder='Reason(s) as to why you are revoking this punishment...' name='reason-$id'></textarea>";
print " <button style='width: 50%; float: right;' class='btn btn-primary' type='submit' name='revoke_pun-$id'>Revoke Punishment</button>";
print " </form>";
print " </div>";
print " </div>";
print " </div>";
print "</div>";
答案 0 :(得分:0)
你的意思是生成一个不同的PHP文件?是的,您可以:而不是回显/打印,只需将内容写入文件(file_put_contents)。
然而,我觉得,虽然这回答了你的问题,但你的问题可能是错误的。你想要完成什么?