在php中插入html和php
我有这行代码在php中插入html和php,php,html,insert,Php,Html,Insert,我有这行代码 <?php if ( current_theme_supports( 'breadcrumb-trail' ) ) breadcrumb_trail( array( 'container' => 'nav', 'separator' => '>', 'before' => __( 'You are here:', 'chun' ) ) ); ?> 如何插入以下代码来替换“You is here”部分 <a href="http://
<?php if ( current_theme_supports( 'breadcrumb-trail' ) ) breadcrumb_trail( array( 'container' => 'nav', 'separator' => '>', 'before' => __( 'You are here:', 'chun' ) ) ); ?>
如何插入以下代码来替换“You is here”部分
<a href="http://myblog.com"><img src="http://myblog/img/mini-gek.gif" alt="Home" title="Home"></a>
<span class="issue-num">The Itinerant | <?php echo do_shortcode("[issuem_issue_title]"); ?>
</span>
巡回者|
我不确定如何正确地分解它。这应该可以:
<?php if ( current_theme_supports( 'breadcrumb-trail' ) ) breadcrumb_trail( array( 'container' => 'nav', 'separator' => '>', 'before' => __( ' <a href="http://myblog.com"><img src="http://myblog/img/mini-gek.gif" alt="Home" title="Home"></a>
<span class="issue-num">The Itinerant | '.do_shortcode("[issuem_issue_title]").'
</span>', 'chun' ) ) ); ?>
<?php if ( current_theme_supports( 'breadcrumb-trail' ) ) breadcrumb_trail( array( 'container' => 'nav', 'separator' => '>', 'before' => '<a href="http://myblog.com"><img src="http://myblog/img/mini-gek.gif" alt="Home" title="Home"></a>
<span class="issue-num">The Itinerant | ' .do_shortcode("[issuem_issue_title]") .'</span>'
)); ?>
这应该可以:
<?php if ( current_theme_supports( 'breadcrumb-trail' ) ) breadcrumb_trail( array( 'container' => 'nav', 'separator' => '>', 'before' => '<a href="http://myblog.com"><img src="http://myblog/img/mini-gek.gif" alt="Home" title="Home"></a>
<span class="issue-num">The Itinerant | ' .do_shortcode("[issuem_issue_title]") .'</span>'
)); ?>
只需添加一个变量来保存要替换的文本。。。像这样:
$some_value = do_shortcode("[issuem_issue_title]");
$replace_with = <<< some_placeholder
<a href="http://myblog.com"><img src="http://myblog/img/mini-gek.gif" alt="Home" title="Home"></a>
<span class="issue-num">The Itinerant | $some_value
</span>
some_placeholder;
编辑:刚刚意识到我在文本中有php
代码,所以我将它移到了另一个变量的外部。只需添加一个变量来保存要替换的文本。。。像这样:
$some_value = do_shortcode("[issuem_issue_title]");
$replace_with = <<< some_placeholder
<a href="http://myblog.com"><img src="http://myblog/img/mini-gek.gif" alt="Home" title="Home"></a>
<span class="issue-num">The Itinerant | $some_value
</span>
some_placeholder;
编辑:刚刚意识到我在文本中有php
代码,所以我把它移到了另一个变量的外部。您正在使用一个框架。哪一个?他在用WordPress你在用框架。哪一个?他在用WordPress这很好但有点复杂。不过,我正在保存这篇文章以供其他地方使用,谢谢。@demonboy很高兴能以某种方式为您服务,多亏了您的评论,我意识到我的文本区域中有php代码,所以我把它移到了外部,这样它至少可以运行。谢谢你也很好但有点复杂。不过,我正在保存这篇文章以供其他地方使用,谢谢。@demonboy很高兴能以某种方式为您服务,多亏了您的评论,我意识到我的文本区域中有php代码,所以我把它移到了外部,这样它至少可以运行。所以也谢谢你