【问题标题】:Inserting html href link via echo mid sentence in php在 php 中通过 echo mid 语句插入 html href 链接
【发布时间】:2021-10-20 10:46:39
【问题描述】:

我是 php 新手,所以这可能是一个乏味的问题,但我正在尝试在我的 php 代码中插入一个 href 链接。我看到了如何做到这一点,但我不确定如何使用 echo 以便我可以在它之前和之后有文本。我尝试使用连接符号 (.),但出现编译错误。我希望链接在一些文字之后出现。这个链接后面也会有文字。这是我目前拥有的:

Session::flash('demo', "You're using a demo account - the changes that you make will not be stored. Learn more ".echo" <a href=$learnMore> here </a>");

感觉很不对劲,但我不知道如何解决,因为这是我第一次用这种语言写作。有什么建议吗?非常感谢:)

【问题讨论】:

  • 不确定您使用的是哪个框架,但我很确定它应该更像:Session::flash('demo', "You're using a demo account - the changes that you make will not be stored. Learn more <a href='".$learnMore."'> here </a>");
  • 谢谢!那行得通。

标签: php html href


【解决方案1】:

不确定您使用的是哪个框架,但我很确定它应该更像:

Session::flash('demo', "You're using a demo account - the changes that you make will not be stored. Learn more <a href='".$learnMore."'> here </a>");

您将字符串传递给一个名为 flash 的方法,因此无需使用 echo 方法来执行任何操作。相反,只需将您的变量连接到上面的字符串中

【讨论】:

    猜你喜欢
    • 2013-09-25
    • 1970-01-01
    • 2014-12-14
    • 2012-09-16
    • 1970-01-01
    • 1970-01-01
    • 2019-05-26
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多