在html文件中嵌入php代码时会发现页面显示并没有达到预期效果,
例如下面的一段代码
<?php echo '1111'; ?> <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <title></title> <link rel="stylesheet" href=""> </head> <body> <form action="indexdo.php" method="post"> <table align="center" border="1" cellspacing="0" cellpadding="0" width="800"> <tr> <td>用户名:</td> <td><input type="text" name="uname"></td> </tr> <tr> <td>密码:</td> <td><input type="password" name="password"></td> </tr> <tr> <td>电话</td> <td><input type="tel" name="tel"></td> </tr> <tr> <td>邮箱</td> <td><input type="email" name="email"></td> </tr> <tr> <td>注册</td> <td><input type="submit" val="注册 "></td> </tr> </table> </form> </body> </html>
结果页面没有输出,打开控制台看了下,竟然自动把php代码注释了。。。。
原因是服务器在解析html文件时没有解析php代码部分,除了修改后缀名为php之外还可以修改httpd.conf文件,具体修改如下:
将
AddType application/x-httpd-php .php .phtml
修改为
AddType application/x-httpd-php .html .htm .php .phtml
然后重启apache就可以了
发表评论
侧栏公告
寄语
譬如朝露博客是一个分享前端知识的网站,联系方式11523518。
热评文章
标签列表
热门文章
友情链接