在php文件里面插入文件html

有的时候我们得在php文件里面引入html代码,或者在php文件的某个位置引入文件html,下面就介绍一下实现的方法。

下面是recharge.php的代码:

<?php
  require_once "../../config.php";
?>
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>充值</title> <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"> <link rel="stylesheet" href="../common/css/header.css" /> <link rel="stylesheet" href="css/recharge.css"> <link href="https://cdnjs.cloudflare.com/ajax/libs/toastr.js/latest/toastr.min.css" rel="stylesheet" /> <script src="http://i.gtimg.cn/qzone/biz/gdt/lib/jquery/jquery-2.1.4.js?max_age=31536000"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/toastr.js/latest/toastr.min.js"></script> <script src="../common/js/common.js"></script> <script src="../config.js"></script> <script src="js/recharge.js"></script> </head> <body> <script type="text/javascript"> var serviceChargePoint = <?php echo $redbag_cash_in_point;?>; </script>
	<!-- 引入公共模块:只有logo的导航条 -->
  <?php include_once('../common/header2.html'); ?>

 <div class="rechargeDiv"> <h2>充值到账户</h2> <p>当前账户余额:<span class="balance" id="balance">0.00</span>元</p> <input type="text" name="data" class="rechargeInput" placeholder="请输入充值数额(元)" id="rechargeInput" οnkeyup="calculatePoundage()"> <p class="poundage">手续费<span class="poundageMoney" id="poundageMoney" name="result">0.00</span>元(手续费=充值金额*<?php echo $redbag_cash_in_point;?>%)</p> <p>需支付:<span class="pay" id="pay">0.00</span>元</p> <span class="example">例如:您充值22元,则共需支付22+22*<?php echo $redbag_cash_in_point;?>%=24.2元</span> <button type="button" class="rechargeBtn" id="rechargeBtn">充值</button> </div> </body>
</html>

我们可以在php文件里面直接写html的标签,用来显示页面的。

也可以在<body></body>标签的任意位置引入文件html,如下面的形式:

  <?php include_once('../common/header2.html'); ?>

注意:路径一定要正确

    原文作者:赏花赏景赏时光
    原文地址: https://blog.csdn.net/tangxiujiang/article/details/78231972
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞