duangonglian6028
2016-10-06 14:11
浏览 51
已采纳

HTML自动将php标记转换为注释

I'm including 'success.php' into 'create.php' but my php code on 'create.php' is getting auto-commented (html tag)

create.php

<html>
        <head>
                <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
                <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" integrity="sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp" crossorigin="anonymous">
                <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.min.js" integrity="sha256-hVVnYaiADRTO2PzUGmuLJr8BLUSjGIZsDYGmIJLv2b8=" crossorigin="anonymous"></script>
                <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
        </head>
        <body>
                <?php
                require("header.php");

                $amount = str_replace(array(".", ","), "", $_POST["amount"]);

                $data = array(
                                "amount"          => $amount,
                                "payment_method"  => $_POST["payment_method"],
                                "customer"        => $_POST["customer"],
                                "installments"    => $_POST["installments"]);

                if ($data["payment_method"] == "credit_card") {
                        $data += $_POST["card"];
                }


                try {
                        $transaction = new PagarMe_Transaction($data);
                        $transaction->charge();
                        require("success.php");
                } catch(Exception $e) {
                        echo $e->getMessage();
                }

                ?>
        </body>
</html>

success.php

<div class="container" style="padding-bottom:100px">
        <div class="page-header">
                <h1>Guide Life</h1>
        </div>
        <div class="alert alert-success" role="alert">
                <b>Transação efetuada com sucesso!</b>
        </div>
        <? if ($transaction->payment_method == "boleto") { ?>
                <p>
                        Link para o boleto:
                        <a target="_blank" href=""></a>
                        <iframe src="https://api.pagar.me/1/boletos/live_citxbiz9d0kg9gu3e33cwmdwr" width="100%" height="100%" />
                </p>
        <? } ?>
</div>

Page:

enter image description here

Html code generated:

enter image description here

</div>
  • 写回答
  • 好问题 提建议
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • dpgua04022 2016-10-06 14:13
    已采纳

    <? if ($transaction->payment_method == "boleto") { ?>

    Needs to have the correct open tag <?php same with <? } ?> should be <?php } ?>

    已采纳该答案
    评论
    解决 无用
    打赏 举报

相关推荐 更多相似问题