所以我尝试使用php echo功能将我链接到我网站上的另一个页面。然而,它打印出我要求的按钮,但它也会打印出其他内容,例如引号中的句点和半冒号以及结束的php标记。
<?php $name = "";echo "<a href='../heroes/" . get_strength_hero($name) . ".html'>" . "<button type='button' class='btn btn-default'>Strength</a></button>";?>
这是回复按钮以及其他元素的PHP代码。
<!DOCTYPE html>
<html class="full" lang="en">
<!-- Make sure the <html> tag is set to the .full CSS class. Change the background image in the full.css file. -->
<head>
<link rel="stylesheet" href="animate.css">
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<script src="../includes/functions.php"></script>
<title>ABADDON</title>
<!-- Bootstrap Core CSS -->
<link href="css/bootstrap.min.css" rel="stylesheet">
<link href="css/hero.css" rel="stylesheet">
<!-- Custom CSS -->
<link href="css/the-big-picture.css" rel="stylesheet">
</head>
<body>
<!-- Navigation -->
<nav class="navbar navbar-inverse navbar-fixed-bottom" role="navigation">
<div class="container">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#">All</a>
</div>
<!-- Collect the nav links, forms, and other content for toggling -->
<div id="navbarItems" class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav">
<li>
<?php $name = "";echo "<a href='../heroes/" . get_strength_hero($name) . ".html'>" . "<button type='button' class='btn btn-default'>Strength</a></button>";?>
</li>
<li>
<a href="#">Agility</a>
</li>
<li>
<a href="#">Intelligence</a>
</li>
</ul>
</div>
<!-- /.navbar-collapse -->
</div>
<!-- /.container -->
</nav>
<!-- Page Content -->
<h1 id="heroName" class="animated fadeInDown">Abaddon</h1>
<br>
<h2 id="slogan">
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Magni, iusto, unde, sunt incidunt id sapiente rerum soluta voluptate harum veniam fuga odit ea pariatur vel eaque sint sequi tenetur eligendi.</p>
<br>
<br>
<br>
<br>
<br>
<br>
<div id="heroportrait">
<video width="450" height="300" autoplay loop>
<source src="heroports/abaddon.webm.webm" type="video/webm" />
</video>
</div>
<!-- /.container -->
<!-- jQuery Version 1.11.0 -->
<script src="js/jquery-1.11.0.js"></script>
<!-- Bootstrap Core JavaScript -->
<script src="js/bootstrap.min.js"></script>
</body>
</html>
这是整个代码。
答案 0 :(得分:1)
这是一个简单的解决方案:
<a href="../heroes/<a href="../heroes/<?php echo get_strength_hero($name); ?>.html"><button type='button' class='btn btn-default'>Strength</button></a>"><button type="button" class="btn btn-default">Strength</button></a>
那应该适合你。