PHP里面的HTML评论/标签

时间:2014-02-28 18:06:40

标签: php html

好的,这是我的头脑

<head>

<meta charset="utf-8">
<title><?php echo $title ?></title>
<meta name="description" content="<?php echo $metadescription ?>">
<meta name="author" content="Talk About Film">

</head>

和我的网页

<?php 
$title ="Talk About Film | Trailers | <?php echo the_field('trailer_title'); ?>";
$metadescription= "Watch the latest trailer for <?php echo the_field('trailer_title'); ?>, watch the latest trailers at Talk About Film";
include 'includes/header.php' ?>

在源代码中,PHP标记不显示它从字段中提取的内容。即

 <title>Talk About Film | Trailers | <?php the_field('trailer_title'); ?></title>

不确定您是否可以这种方式使用PHP,或者是否有简单的修复方法?

2 个答案:

答案 0 :(得分:1)

当你打开另一个时,你已经在<?php ?>区块内了。将其更改为:

<?php 
$title ="Talk About Film | Trailers | ".the_field('trailer_title');
$metadescription= "Watch the latest trailer for ".the_field('trailer_title').", watch the latest trailers at Talk About Film";
include 'includes/header.php' ?>

答案 1 :(得分:1)

<?php 
$title ="Talk About Film | Trailers | <?php echo the_field('trailer_title'); ?>";
$metadescription= "Watch the latest trailer for <?php echo the_field('trailer_title'); ?>, watch the latest trailers at Talk About Film";
include 'includes/header.php' ?>

应该是

<?php 
$title ="Talk About Film | Trailers | " . the_field('trailer_title');
$metadescription= "Watch the latest trailer for " . the_field('trailer_title') . ", watch the latest trailers at Talk About Film";
include 'includes/header.php' ?>