php echo在html

时间:2016-04-05 20:06:29

标签: php html twitter-bootstrap

我在使用html

中的引导按钮获取php值时遇到了一些麻烦

这是我的代码:

<html>
<head>
    <title>Samples</title>
    <!-- Latest compiled and minified CSS -->
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous">

    <!-- Optional theme -->
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap-theme.min.css" integrity="sha384-fLW2N01lMqjakBkx3l/M9EahuwpSfeNvV63J5ezn3uZzapT0u7EYsXMjQV+0En5r" crossorigin="anonymous">

    <!-- Latest compiled and minified JavaScript -->
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js" integrity="sha384-0mSbJDEHialfmuBBQP6A4Qrprq5OVfW37PRR3j5ELqxss1yVqOtnepnHVP9aJ7xS" crossorigin="anonymous"></script>
</head>
<body>
<a href="#" class="btn btn-info" role="button"><?php echo "Samples"; ?> Stuff</a>
</body>
</html>

因此,按钮只是简单地说“Stuff”,而不是按钮说“Samples Stuff”。重要的是按钮取一个php值,因为最终我会在按钮中放入一个db值 - 但我甚至无法使基本工作正常工作

为什么不起作用?

3 个答案:

答案 0 :(得分:0)

您是否正在运行本地托管的服务器。如果没有,您可能应该安装XAMPP。确保文件的扩展名为.php,我没有看到任何其他原因导致简单的回声不起作用。

答案 1 :(得分:-1)

确保文件扩展名以.php结尾。还要确保正确配置了php / apache。

尝试查看错误日志,看看是否有任何内容

答案 2 :(得分:-2)

首先确保您的文件扩展名为.php,然后确保在启用php的Web服务器上运行.php文件。只需在浏览器上查看php文件就不会真正编译php。这是在服务器的后端完成的。