php使用include制作模板页

来源:互联网 发布:软件测试个人职业规划 编辑:程序博客网 时间:2024/06/05 15:25

 
<templete.php>关键在Templete中使用include $content,在随后的页面中使用templete模板页面之前指定$content的内容。

<!DOCTYPE html><html>    <head>        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">        <title>your website</title>    </head>    <body>      <?php        include $content;       ?>    </body></html>

index.php

        <?php              $content="controlers/gobuy.php";         include"templete/templete.php";                      ?>

controlers/gobuy.php

<?php$conn=  mysql_connect('localhost','root','');mysql_select_db("engineering",$conn);if (mysqli_connect_errno()){    echo 'error:could not coonect mysql'.  mysql_errno();    exit;}$result = mysql_query("SELECT * FROM users");while($row=  mysql_fetch_array($result))echo $row['name'];?>



原创粉丝点击