【问题标题】:PHP: Edit href in <a> link [duplicate]PHP:在 <a> 链接中编辑 href [重复]
【发布时间】:2020-02-23 01:27:25
【问题描述】:

我想将 URL 编辑为特定 URL,因为在 WordPress 和 cPanel 的 phpMyAdmin 中都找不到用户元数据。

我想改变这个:

if(get_user_meta( $user_id, 'googleplus', $single) !=""){
  echo "<br/><a class='author-link g' title='Follow on Google+' href=".get_user_meta( $user_id, googleplus', $single )." target='_blank'>Google+</a>";
  }

收件人:

if(get_user_meta( $user_id, 'googleplus', $single) !=""){
  echo "<br/><a class='author-link g' title='Follow on Google+' href="https://example.com" target='_blank'>Google+</a>";
  }

错误是:

syntax error, unexpected 'https' (T_STRING), expecting ',' or ';'

我试过了:

href="<?php echo "http://www.example.com"; ?>"
href="https:\/\/www.example.com"
href="https://www.example.com"

感谢任何建议,因为我对 PHP 的了解为零。

【问题讨论】:

    标签: php wordpress href


    【解决方案1】:

    您在使用single quoteddouble quoted 时出错 在你的代码中 将 "example.com" 更改为 'example.com' 或者像这样使用它 \"example.com\" 来转义双引号

    最终正确的代码是

    if(get_user_meta( $user_id, 'googleplus', $single) !=""){
      echo "<br/><a class='author-link g' title='Follow on Google+' href='https://example.com' target='_blank'>Google+</a>";
      }
    

    【讨论】:

      【解决方案2】:

      改变

       echo "<br/><a class='author-link g' title='Follow on Google+' href="https://example.com" target='_blank'>Google+</a>";
      

       echo '<br/><a class="author-link g" title="Follow on Google+" href="https://example.com" target="_blank">Google+</a>';
      

      【讨论】:

      • tnx,接受答案。
      • 当然可以,但它允许我在 6 分钟内接受它。届时会这样做。干杯伙伴。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-04-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-06-06
      • 2014-06-10
      • 1970-01-01
      相关资源
      最近更新 更多