简体   繁体   English

在echo标签内链接PHP

[英]Link PHP inside an echo tag

I am having a problem with this code 我对此代码有疑问

 <?php
echo '<div class="post_note2">
<b>'.$lang['RENEW_SUCCESS'].'</b></div><br /><span class="orange"><b><a href="?view=main">HOME</a>|<a href="<?php echo $adurl; ?>">VIEW AD</a></b></span>';

        }
}?>

for some reason when the VIEW AD link is clicked it doesn't build it properly and still contains the php code in the link rather than the link to the actual ad page. 由于某些原因,当点击VIEW AD链接时,它无法正确构建,并且仍在链接中包含php代码,而不是实际广告页面的链接。 is it an issue with an echo in an echo ? 回声中的回声有问题吗? I'm sure this isn't quite difficult to solve but I have been trying for far to long on my own and cant get it. 我确信这并不是很难解决,但是我已经尝试了很长时间了,并且无法做到。 Thanks, any help would be great. 谢谢,任何帮助都会很棒。

You actually had it right in the first part of your string. 实际上,您已经在字符串的第一部分中找到了它。 You can't have and echo statement inside of another echo statement. 您不能在另一个echo语句中包含and echo语句。 Use concatenation throughout your string: 在整个字符串中使用串联:

<a href="' . $adurl . '"

You have two extra brackets at the end and php text inside your echo. 您在末尾有两个额外的括号,在回显中包含php文本。

<?php
    echo '
        <div class="post_note2">
        <b>'.$lang['RENEW_SUCCESS'].'</b>
    </div>
    <br />
    <span class="orange">
        <b>
            <a href="?view=main">HOME</a> | <a href="' . $adurl . '">VIEW AD</a>
        </b>
    </span>';
?>

All fixed given that $adurl is defined. 给定$ adurl的所有固定值。

This 这个

<?php echo $adurl; ?>

Should be 应该

' . $adurl . '

ie

echo '<div class="post_note2"><b>'.$lang['RENEW_SUCCESS'].'</b></div><br /><span class="orange"><b><a href="?view=main">HOME</a>|<a href="'.$adurl.'>VIEW AD</a></b></span>';

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM